I have an array that looks like this:
Array ( [0] => Array ( [filters] => Array ( [filter_1] => 1
[filt
You'll need to use the uasort function. Try something like this:
function cmp($a, $b) {
if ($a["count"] == $b["count"]) {
return 0;
}
return ($a["count"] > $b["count"]) ? -1 : 1;
}
uasort($array, 'cmp');
You definitely want the usort function. You can define how the sort function determines which is larger or smaller.
If it's alright that each sub-array (of "filters" and "count") gets re-indexed, this should work perfectly. By re-indexed, I mean the newly sorted array would start at 0, progress to 1, etc. This is almost always how you want it, unless your original array is associative.
For example:
usort($array, "byCount");
function byCount($a, $b)
{
if( $a['count'] == $b['count'] )
{
return 0;
}
return ($a['count'] < $b['count']) ? -1 : 1;
}