Voting

: min(one, six)?
(Example: nine)

The Note You're Voting On

ssb45 at cornell dot edu
20 years ago
The function that justin at booleangate dot org provides works well, but be aware that it is not a drop-in replacement for ksort as is. While ksort sorts the array by reference and returns a status boolean, natksort returns the sorted array, leaving the original untouched. Thus, you must use this syntax:

$array = natksort($array);

If you want to use the more natural syntax:

$status = natksort($array);

Then use this modified version:

function natksort(&$array) {
$keys = array_keys($array);
natcasesort($keys);

foreach ($keys as $k) {
$new_array[$k] = $array[$k];
}

$array = $new_array;
return true;
}

<< Back to user notes page

To Top