英[sɔ:t]   美[sɔ:rt]   

n.Classification, category; quality, nature; method; a group

vt.& vi.Classification; rectification, arrangement ; suitable for

vt. to select; to classify; to put in order

vi. to classify; to communicate; to coordinate

Third person singular: sorts Plural: sorts Present participle: sorting past tense: sorted past participle: sorted

php natsort() function syntax

Function:Use the "natural sorting" algorithm to sort the array. Key values retain their original key names.

Syntax:natsort(array)

Parameters:

Parameter Description
array Required. Specifies the array to be sorted.

Explanation:In the natural sorting algorithm, the number 2 is less than the number 10. In computer sorting algorithms, 10 is less than 2 because the first number in "10" is less than 2.

php natsort() function example


Run instance»

Click the "Run instance" button to view the online instance

Output:

Array ( [2] => string01 [5] => string02 [0] => string1 [3] => string2 [1] => string10 [4] => string20 )