I've always assumed that sort
without any additional arguments, will sort a file in lexical order.
However today I ran across following test case:
sort test2.txt
a/a
a/c
a//c
a/d
As you can see the third line has two slashes, so the second slash is in a place where neighboring lines have letters 'c' and 'd' respectively. I doubt that '/' comes between 'c' and 'd' in any code-page, so I guess that the default comparison algorithm is not strictly lexical.
Is there some pre-processing (like removing non-letters?) or special cases (like "a sequence of one or more symbols is equal to any other sequence of symbols"?) for comparing symbols?
I've read man
page for sort
but I found no enlightenment there.
I use
sort --version
sort (GNU coreutils) 8.5
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by Mike Haertel and Paul Eggert.
and I really need to sort millions of URLs for further analysis which assumes lexical ordering - are there any options which I could pass to sort
to achieve this?