Sorting an associative array in PHP [duplicate]

Use usort and supply your own function to do the ordering, e.g.

function cmp($a, $b)
{
    return $b['avgSearchVolume'] - $a['avgSearchVolume'];
}

usort($array, "cmp");

Leave a Comment