Unix and Linux Discussions Tagged with sorting |
|
Thread / Thread Starter |
Last Post |
Replies |
Views |
Forum |
|
|
|
7 |
5,057 |
UNIX for Beginners Questions & Answers |
|
|
|
15 |
13,239 |
Shell Programming and Scripting |
|
|
|
4 |
5,794 |
Shell Programming and Scripting |
|
|
|
4 |
1,625 |
UNIX for Beginners Questions & Answers |
|
|
|
5 |
3,135 |
Shell Programming and Scripting |
|
|
|
1 |
546 |
UNIX for Beginners Questions & Answers |
|
|
|
3 |
2,320 |
Shell Programming and Scripting |
|
|
|
1 |
2,644 |
UNIX for Beginners Questions & Answers |
|
|
|
4 |
1,188 |
Shell Programming and Scripting |
|
|
|
7 |
1,997 |
Shell Programming and Scripting |
|
|
|
5 |
2,069 |
AIX |
|
|
|
3 |
2,163 |
Shell Programming and Scripting |
|
|
|
5 |
7,683 |
Shell Programming and Scripting |
|
|
|
2 |
1,682 |
Shell Programming and Scripting |
|
|
|
12 |
4,723 |
UNIX for Dummies Questions & Answers |
|
|
|
10 |
11,954 |
Shell Programming and Scripting |
|
|
|
3 |
1,951 |
Shell Programming and Scripting |
|
|
|
7 |
2,441 |
UNIX for Dummies Questions & Answers |
|
|
|
3 |
4,432 |
Shell Programming and Scripting |
|
|
|
7 |
10,375 |
Shell Programming and Scripting |
|
|
|
8 |
9,004 |
Shell Programming and Scripting |
|
|
|
2 |
1,759 |
Shell Programming and Scripting |
|
|
|
2 |
9,021 |
Shell Programming and Scripting |
|
|
|
10 |
5,927 |
Shell Programming and Scripting |
|
|
|
2 |
1,680 |
UNIX for Advanced & Expert Users |
|
|
|
1 |
3,640 |
Shell Programming and Scripting |
|
|
|
1 |
10,541 |
Shell Programming and Scripting |
|
|
|
5 |
5,885 |
Shell Programming and Scripting |
|
|
|
9 |
7,636 |
UNIX for Advanced & Expert Users |
|
|
|
4 |
22,506 |
Shell Programming and Scripting |
|
|
|
5 |
2,315 |
UNIX for Dummies Questions & Answers |
|
|
|
2 |
1,485 |
Shell Programming and Scripting |
|
|
|
3 |
1,488 |
Shell Programming and Scripting |
|
|
|
3 |
1,976 |
Shell Programming and Scripting |
|
|
|
4 |
4,578 |
Shell Programming and Scripting |
|
|
|
1 |
10,111 |
Shell Programming and Scripting |
|
|
|
2 |
5,484 |
UNIX for Dummies Questions & Answers |
|
|
|
6 |
2,746 |
UNIX for Dummies Questions & Answers |
|
|
|
0 |
2,201 |
Shell Programming and Scripting |
|
|
|
9 |
3,827 |
Shell Programming and Scripting |
NATCASESORT(3) 1 NATCASESORT(3)
natcasesort - Sort an array using a case insensitive "natural order" algorithm
SYNOPSIS
bool natcasesort (array &$array)
DESCRIPTION
natcasesort(3) is a case insensitive version of natsort(3).
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".
PARAMETERS
o $array
- The input array.
RETURN VALUES
Returns TRUE on success or FALSE on failure.
EXAMPLES
Example #1
natcasesort(3) example
<?php
$array1 = $array2 = array('IMG0.png', 'img12.png', 'img10.png', 'img2.png', 'img1.png', 'IMG3.png');
sort($array1);
echo "Standard sorting
";
print_r($array1);
natcasesort($array2);
echo "
Natural order sorting (case-insensitive)
";
print_r($array2);
?>
The above example will output:
Standard sorting
Array
(
[0] => IMG0.png
[1] => IMG3.png
[2] => img1.png
[3] => img10.png
[4] => img12.png
[5] => img2.png
)
Natural order sorting (case-insensitive)
Array
(
[0] => IMG0.png
[4] => img1.png
[3] => img2.png
[5] => IMG3.png
[2] => img10.png
[1] => img12.png
)
For more information see: Martin Pool's Natural Order String Comparison page.
SEE ALSO
natsort(3), The comparison of array sorting functions, strnatcmp(3), strnatcasecmp(3).
PHP Documentation Group NATCASESORT(3)