PDA

View Full Version : Sorting a multidimensional array...


Jaxel
06-30-2009, 02:27 PM
Well I'm back to programming... but I'm having trouble figuring this out... I want to do this with as LITTLE code as possible...

I have an array:

$id $arr[$id]['w'] $arr[$id]['l']
Anduril 22 7
Derb 5 24
jimmychoi 25 3
Link-WI 7 21
Lokim 14 14
Mary-dono 5 25
Max 11 17
Metallix 6 24
MysticBill 25 2
Ora 21 8
Outlaw 18 9
Phil Bond 20 8
Pouncer 7 23
Tomi 13 14

Now I want to sort this multidimensional array... It should sort it in the following priority:

['w'] DESC, ['l'] ASC

What that means, it should sort by the highest number of "wins" first, and then break ties by the lowest number of "losses". Does anyone know a simple way to do this?

Andreas
06-30-2009, 05:15 PM
<a href="http://de.php.net/manual/en/function.uasort.php" target="_blank">http://de.php.net/manual/en/function.uasort.php</a>