i have the following array and i want to sort this array in descending order on the base of the "count" index value in php. i have used the following code but it is not working for me. please give me hint to sort array in descending order.
Array:-
Array ( [0] => Array ( [text] => this is text [count] => 0 )
[1] => Array ( [text] => this is second text [count] => 2 )
[2] => Array ( [text] => this is third text [count] => 1 )
)
I have tried the following code.
function sort_count($a, $b) {
return $a['count'] - $b['count'];
}
$sorted_array = usort($array, 'sort_count');