PHP 4, PHP 5, PHP 7, PHP 8
natsort - Sort an array using a "natural order" algorithm
array ): bool
This function implements a sort algorithm that orders alphanumeric strings in the way a human being would while maintaining key/value associations. This is described as a "natural ordering". An example of the difference between this algorithm and the regular computer string sorting algorithms (used in sort) can be seen in the example below.
If two members compare as equal, they retain their original order. Prior to PHP 8.0.0, their relative order in the sorted array was undefined.
Resets array's internal pointer to the first element.
The input array.
Always returns true.
Show all examples for natsort