The natcasesort() function is an inbuilt function in PHP which is used to sort an array by using a “natural order” algorithm. The natural order tells the order to be used as a normal human being would use. That is, it does not check the type of value for comparison. For example, in string representation 30 is less than 7 according to the standard sorting algorithm as 3 comes before 7 lexicographically. But in natural order 30 is greater than 7. Also, the natcasesort() function is case insensitive.
bool natcasesort($array )
Parameters: This function accepts a single parameter $array. It is the array which natcasesort() function is going to sort.
Return Value It returns a boolean value i.e., TRUE on success and FALSE on failure.
Below programs illustrate the natcasesort() function in PHP:
Standard sorting: Array (  => Gfg12.jpeg  => Gfg2.jpeg  => gfg1.jpeg  => gfg10.jpeg ) Natural order case insensitve: Array (  => gfg1.jpeg  => Gfg2.jpeg  => gfg10.jpeg  => Gfg12.jpeg )
Array (  => Gfg1.jpeg  => Gfg2.jpeg  => gfg10.jpeg  => Gfg15.jpeg  => gfg22.jpeg )
- ArrayObject natcasesort() Function in PHP
- How to get the function name inside a function in PHP ?
- PHP | Ds\Map put() Function
- PHP | pi( ) Function
- PHP | pow( ) Function
- PHP | each() Function
- PHP | Ds\Map xor() Function
- D3.js | d3.max() function
- PHP Ds\Set get() Function
- PHP Ds\Set sum() Function
- PHP | pos() Function
- PHP | key() Function
- p5.js | nf() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.