The php Function Array_Multisort
If you need to sort a large array of values, this php function can do the job very well. The
There are three arguments to the array_multisort() function: an array, a sort order and a sort flag. The first array is the one being sorted, the sort order is the one used to sort the previous array, and the flag indicates which sorting type is used (SORT_ASC, SORT_DESC or SORT_REGULAR).
The string keys are maintained while numeric keys are re-indexed starting from 0. If two members on comparison become equal, their relative order in the resulting sorted array is undefined.
The SORT_REGULAR and SORT_LOCALE_STRING sorting types are case sensitive. This means that strings that start with a capital letter will come before strings that start with a lowercase letter. Using these sorts can help you make sure your data is sorted properly by your customers. For example, if you are displaying a list of book titles in alphabetical order. If you want to also show them by publication year or author name, you need to sort the titles twice: once by the title and once by the author's name. This can be achieved by using the ksort function instead of array_multisort().