PHP uasort() Function

The uasort() function is used to sort an array by its values using a user-defined comparison function.The function maintains the existing key index.This function sorts an array such that array indices maintain their correlation with the array elements they are associated with, using a user-defined comparison function.This is used mainly when sorting associative arrays where the actual element order is significant.The uasort() function sorts an array by values using a user-defined comparison function.

Example -

Example -