PHP's asort does not work properly?

elkibeer

New Member
I have an example array:\[code\]$a = array( 5 => 35, 16 => 22, 7 => 22, 3 => 22, 11 => 22, 9 => 27,);\[/code\]and I want to sort it by values and remember its keys.Result that I expected was:\[code\]$a = array( 16 => 22, 7 => 22, 3 => 22, 11 => 22, 9 => 27, 5 => 35,);\[/code\]So my first thought was: \[code\]asort\[/code\] !Ok, I did\[code\]asort($a);\[/code\]But no - it didn't just move \[code\]5 => 35\[/code\] to the end of the array.It changed my array to:\[code\]$a = array( 11 => 22, 3 => 22, 7 => 22, 16 => 22, 9 => 27, 5 => 35);\[/code\]You see ? Keys with the same value are reverse sorted. Why ?
 
Back
Top