0
I’ve tried every way.
The pure array is like this:
Array
(
[71] => 100
[70] => 100
[69] => 23.53
[68] => 74.07
[67] => 23.29
[66] => 61.01
[59] => 100
[3] => 35
[1] => 56.18
)
When I apply a asort($array)
gets like this:
Array
(
[67] => 23.29
[69] => 23.53
[3] => 35
[1] => 56.18
[66] => 61.01
[68] => 74.07
[71] => 100
[70] => 100
[59] => 100
)
When I try a rsort($array)
, loses the original value of Key.
Array
(
[0] => 100
[1] => 100
[2] => 100
[3] => 74.07
[4] => 61.01
[5] => 56.18
[6] => 35
[7] => 23.53
[8] => 23.29
)
I need you to stay like this:
Array
(
[59] => 100
[70] => 100
[71] => 100
[68] => 74.07
[66] => 61.01
[1] => 56.18
[3] => 35
[69] => 23.53
[67] => 23.29
)
If it was a SELECT in Mysql, it would be easy. Just apply an ORDER BY DESC KEY, ASC VALUE. But at Array, I can’t do it.
What is the expected result?
– Wictor Chaves
I edited the question and entered the result I need at the end.
– Jetro Bernardo
Sorting is by value?
– Sr. André Baill
Tried with the uasort?
– renanvm
Tries the
arsort
– Eduardo
The arsort almost worked. All we had to do was let the KEY up. It looks like this: Array ( [71] => 100 [70] => 100 [59] => 100
– Jetro Bernardo