For string comparison, it seems Linux sort assume number < lowercase <
uppercase. However, the ASCII value is: number < uppercase < lowercase.
Thus, the comparison function of Linux sort is different from that of C
function strcmp(). Is this a bug, or it is designed in this way for some
purpose?
Example:
input------------------------------------
echo A > test.txt
echo a >> test.txt
echo 1 >> test.txt
sort test.txt
output------------------------------------
1
a
A
sort --version
sort (coreutils) 5.2.1
Written by Mike Haertel and Paul Eggert.
Copyright (C) 2004 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
In another sort package of BSD, the output is correct:
input------------------------------------
echo A > test.txt
echo a >> test.txt
echo 1 >> test.txt
sort test.txt
output------------------------------------
1
A
a
sort --version
sort - GNU textutils 1.14
--
Lei Guo, PhD candidate
The Ohio State University
Department of Computer Science and Engineering
URL: http://www.cse.ohio-state.edu/~lguo/