Tuesday, July 28, 2009

What is the comparison function of linux sort?

For string comparison, it seems Linux sort assume number %26lt; lowercase %26lt; uppercase. However, the ASCII value is: number %26lt; uppercase %26lt; 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?

What is the comparison function of linux sort?
Does this help:





The default sort order depends on the value of LC_COLLATE.


If LC_COLLATE is set to C, sorting will be in ASCII order.


If LC_COLLATE is set to en_US, sorting is case insensitive


except when the two strings are otherwise equal and one has


an uppercase letter earlier than the other. Other locales


will have other sort orders.


No comments:

Post a Comment