Unix and Linux Discussions Tagged with sorting |
|
Thread / Thread Starter |
Last Post |
Replies |
Views |
Forum |
|
|
|
7 |
6,599 |
UNIX for Beginners Questions & Answers |
|
|
|
15 |
17,097 |
Shell Programming and Scripting |
|
|
|
4 |
6,443 |
Shell Programming and Scripting |
|
|
|
4 |
2,095 |
UNIX for Beginners Questions & Answers |
|
|
|
5 |
3,790 |
Shell Programming and Scripting |
|
|
|
1 |
714 |
UNIX for Beginners Questions & Answers |
|
|
|
3 |
3,133 |
Shell Programming and Scripting |
|
|
|
1 |
3,536 |
UNIX for Beginners Questions & Answers |
|
|
|
4 |
1,592 |
Shell Programming and Scripting |
|
|
|
7 |
2,222 |
Shell Programming and Scripting |
|
|
|
5 |
2,471 |
AIX |
|
|
|
3 |
2,332 |
Shell Programming and Scripting |
|
|
|
5 |
8,164 |
Shell Programming and Scripting |
|
|
|
2 |
1,903 |
Shell Programming and Scripting |
|
|
|
12 |
5,186 |
UNIX for Dummies Questions & Answers |
|
|
|
10 |
12,372 |
Shell Programming and Scripting |
|
|
|
3 |
2,356 |
Shell Programming and Scripting |
|
|
|
7 |
2,876 |
UNIX for Dummies Questions & Answers |
|
|
|
3 |
4,674 |
Shell Programming and Scripting |
|
|
|
7 |
10,732 |
Shell Programming and Scripting |
|
|
|
8 |
9,750 |
Shell Programming and Scripting |
|
|
|
2 |
1,849 |
Shell Programming and Scripting |
|
|
|
2 |
9,210 |
Shell Programming and Scripting |
|
|
|
10 |
6,219 |
Shell Programming and Scripting |
|
|
|
2 |
1,826 |
UNIX for Advanced & Expert Users |
|
|
|
1 |
3,800 |
Shell Programming and Scripting |
|
|
|
1 |
10,810 |
Shell Programming and Scripting |
|
|
|
5 |
6,146 |
Shell Programming and Scripting |
|
|
|
9 |
8,057 |
UNIX for Advanced & Expert Users |
|
|
|
4 |
22,621 |
Shell Programming and Scripting |
|
|
|
5 |
2,514 |
UNIX for Dummies Questions & Answers |
|
|
|
2 |
1,558 |
Shell Programming and Scripting |
|
|
|
3 |
1,582 |
Shell Programming and Scripting |
|
|
|
3 |
2,083 |
Shell Programming and Scripting |
|
|
|
4 |
4,684 |
Shell Programming and Scripting |
|
|
|
1 |
10,291 |
Shell Programming and Scripting |
|
|
|
2 |
5,678 |
UNIX for Dummies Questions & Answers |
|
|
|
6 |
2,890 |
UNIX for Dummies Questions & Answers |
|
|
|
0 |
2,329 |
Shell Programming and Scripting |
|
|
|
9 |
4,228 |
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)