Answer the question
In order to leave comments, you need to log in
Sorting nested arrays
Good day.
Tell me please. I have an array like this:
Array (
[1] => Array ( [name] => Бананы [count] => 16 )
[2] => Array ( [name] => Груши [count] => 12 )
[3] => Array ( [name] => Яблоки [count] => 1 )
[4] => Array ( [name] => Апельсины [count] => 1 )
[5] => Array ( [name] => Мандарины [count] => 5 )
)
Array (
[4] => Array ( [name] => Апельсины [count] => 1 )
[3] => Array ( [name] => Яблоки [count] => 1 )
[5] => Array ( [name] => Мандарины [count] => 5 )
[2] => Array ( [name] => Груши [count] => 12 )
[1] => Array ( [name] => Бананы [count] => 16 )
)
Answer the question
In order to leave comments, you need to log in
5.3+
uksort($arr,function($a,$b){ return $b['count'] - $a['count'];})
I do not really understand. How about writing a quicksort yourself?
Do you say the standard functions do not fit? multisort can't? Or maybe I misunderstood the task, but the result is the same: pastebin.com/L03vF8SX
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question