PHP Function uksort
Article about php function uksort
The uksort() function sorts an array by using a user defined comparison (callback) function. The comparison function determines what is less than, equal to and greater than so that the keys/values association from the original array remains intact. This is useful if you need to sort an array by some non-trivial criteria.
It is used mainly when sorting associative arrays, where the original key-to-value correlations may need to be preserved. In other words, uksort is a way to order alphanumeric strings in the same way that a human would, maintaining the relationship between keys and values, rather than ordering them according to their numerical or alphabetical value.
The function takes the array to be sorted and the comparison function as arguments and returns a boolean value: True on success or False on failure.
To avoid recursion in the comparison function, the function uses two special truthiness operators which look like functions but aren't: empty() and isset(). Using these helps avoid generating PHP warnings for undeclared variables, which is useful if you are working with large and/or complex data structures.
a is the array to be sorted. b is the user-defined comparison function which will compare elements in the array and determine how they should be ordered. c is the original order of the elements in the array and d is the new order that will be used by uksort to sort the array. The uksort function will then take the new index for each element and use it to sort the array. This will preserve the original relationship between key and index, so that if two elements are considered equal by the comparison function, their order in the resulting sorted array will remain the same as it was before.