PHP Function Natcasesort
php function natcasesort is an inbuilt function that sorts the values of the array in a natural order. It does not check for the value type while sorting, it only compares the char-case. This means that 4 comes before 8 if the string is represented in lower case but after 8 if it is represented in upper case (as humans would see them). The function is similar to usort() and asort() but unlike them it preserves the keys of the array instead of assigning new ones during the sorting process.
Another advantage of this function is that it does not return the original array but an unsorted copy of it. Hence, it is faster than these functions.
The function has a few mandatory and optional parameters. The first is the array that needs to be sorted and the second is an array of flags which indicate how the sorting must be performed. The different types of sorting are ascending, descending, alphabetical, natural and random.
Like other sorting functions, the natcasesort() function returns TRUE on success and FALSE on failure. The only other thing to remember is that this is a case-insensitive sort, so the key-to-value mappings must be kept in mind. This is a great tool to use when you are working with associative arrays and need to have them sorted in a way that makes sense to human beings. The function is also very helpful if you are dealing with a database and need to sort the rows in a column or row-based manner.