behaviour of sort command

Dan Christensen jdc at uwo.ca
Mon Jan 23 21:40:24 UTC 2012


PleegWat <pleegwat at telfort.nl> writes:

> On 01/20/2012 10:57 PM, Dan Christensen wrote:
>> Is this a bug in sort?  It's not explained in the man page or the
>> info page, and I think most people would expect that adding text to
>> the end of unequal lines shouldn't change their sort order.
>
> How sort sorts depends on your localization settings (specifically the
> value of LC_COLLATE). Example:

I knew that could change how bytes were compared, but I didn't realize
that it could make sort use later characters on the line instead of
earlier characters!  I've searched many man pages and haven't found
any documentation of this.  Does anyone know what the algorithm is
that produces this output:

> $ LC_COLLATE=en_US.UTF-8
> $ echo -e " 1\n_1\n 2\n_2" | sort
>  1
> _1
>  2
> _2

Thanks,

Dan





More information about the ubuntu-users mailing list