September 2001
Intermediate to advanced
768 pages
32h 45m
English
void natsort(array array) Sorts an array in ascending order by value, using a natural sorting algorithm.
Returns:
Nothing
Description:
This function simply sorts an array in ascending order by element value, keeping key/value relationships intact. However, the algorithm sorts the values as strings according to the rules typically used by humans to order alphanumeric strings. This gives a very natural result.
The basic idea is that any strings of digits embedded within the strings being sorted are compared according to their actual numeric values, and not according to the character codes of the individual digits. For instance, while in a normal computer sort the value b2 would be considered to be greater than b10 (since 1 comes before ...
Read now
Unlock full access