[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: $(sort) - what is "lexical order"? (was RE: Follow-up)

From: Paul Smith
Subject: RE: $(sort) - what is "lexical order"? (was RE: Follow-up)
Date: Tue, 19 Jul 2011 15:00:22 -0400

There is no standard definition of "lexical order" that I'm aware of
that means only, and exactly, sorted according to the current locale
collation definition.  The free dictionary defines it as:

        the arrangement of a set of items in accordance with a recursive
        algorithm, such as the entries in a dictionary whose order
        depends on their first letter unless these are the same in which
        case it is the second which decides, and so on

Which seems reasonable to me.

GNU make uses the standard C runtime function qsort(3) to perform its
sorting, with a comparison function of the standard C runtime function
strcmp().  The strcmp() function is defined by both the ISO C and POSIX
standards to perform byte-wise comparisons; that is, it uses ASCII
sorting order (on systems where the characters are stored as ASCII
chars, which is just about all of them these days).

The builtin sort function DOES sort.  It may not sort the way you would
prefer, but it sorts in a standard, repeatable, well-defined way that
does not change based on a particular user's environment settings...
most creators of build systems consider this reproducibility to be MUCH
more important than locale-specific collation, which is just visual

I agree that the manual should document the fact that the sort function
does not sort according the current LC_COLLATE value but instead always
uses the standard ASCII (or LC_COLLATE="C") order.

But I will not say that it doesn't sort lexically, because that's not
true: it does.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]