natsort php
// create a example array
$array_1 = array(
'pic10.jpg', 'pic3.jpg', 'pic1.jpg',
'pic7.jpg', 'pic99.jpg', 'pic127.jpg'
);
// copy array 1
$array_2 = $array_1;
sort($array_1);
print "Standard sorting algorithm:<br/>\n";
print_r($array_1);
print "\n\n";
natsort($array_2);
print "Natural order sorting:<br/>\n";
print_r($array_2);
/*
Output:
Standard sorting algorithm
Array
(
[0] => pic1.jpg
[1] => pic10.jpg
[2] => pic127.jpg
[3] => pic3.jpg
[4] => pic7.jpg
[5] => pic99.jpg
)
Natural order sorting
Array
(
[2] => pic1.jpg
[1] => pic3.jpg
[3] => pic7.jpg
[0] => pic10.jpg
[4] => pic99.jpg
[5] => pic127.jpg
)
*/