You can use asort function to sort an array by value in a key value pair array. To sort the array by value in descending order use arsort.