PHP usort() Function

The usort() function sorts an array using a user-defined comparison function.The usort() function is used to sort an array by its values using a user-defined comparison function. If the array you wish to sort needs to be sorted by some non-trivial criteria, you should use this function.The function removes any existing keys and assigns new keys for the elements in the array.This function will sort an array by its values using a user-supplied comparison function. If the array you wish to sort needs to be sorted by some non-trivial criteria, you should use this function.

Example -

Example -