How do I sort array that has highest point from 15.00 key?
I have an array look like this:
Array
(
[9] => Array
(
[15.00] => 3.0
[20.00] => 8.0
[25.00] => 10.5
)
[2] => Array
(
[15.00] => 2.0
[20.00] => 5.0
[25.00] => 2.5
)
[4] => Array
(
[15.00] => 6.0
[25.00] => 4.0
[30.00] => 6.0
)
)
In order it should be: 4, 9 and 2
PHP has
usort, a function enabling you to sort via a user-provided comparison function. There’s alsouasortthat maintains index association.Here’s an example:
And here’s it working.
Hope this helps.