Is it even possible to sort an array such that one element (in this case, the element matching the current user) bubbles up to the top, while the rest properly sort underneath it?
I tried to do it with this (yeah, I don’t get closures in my version of PHP, which is a shame) but had no luck.
uasort($output, create_function('$a,$b',
'if( $a["user_id"] == '.$this->user['id'].') { return -1; }'.
'elseif( $b["user_id"] == '.$this->user['id'].') { return -1; }'.
'elseif( $b["percent"] == $a["percent"]) { return strcasecmp($a["username"], $b["username"]);
'elseif($a["percent"] < $b["percent"]) { return 1; }'.
'elseif($a["percent"] > $b["percent"]) { return -1; }'.
'else { return 0; }'
));
I figure this was the best way to do it, since I have to sort the array anyway – but I’m open to suggestions.
Thx in advance.
Best way would probably be to do this: