Gnu/coreutils/Additional-hard 002dcoded-priorities-in-GNU-coreutils 0027-version-sort
From Get docs
Next: Special handling of file extensions, Previous: Minus/Hyphen and Colon characters, Up: Differences from the official Debian Algorithm [Contents][Index]
30.3.2 Additional hard-coded priorities in GNU coreutils’ version sort
In GNU coreutils’ version sort algorithm, the following items have special priority and sort earlier than all other characters (listed in order);
- The empty string
- The string ‘
.
’ (a single dot character, ASCII 46) - The string ‘
..
’ (two dot characters) - Strings start with a dot (‘
.
’) sort earlier than strings starting with any other characters.
Example:
$ printf "%s\n" a "" b "." c ".." ".d20" ".d3" | sort -V . .. .d3 .d20 a b c
These priorities make perfect sense for ‘ls -v
’: The special
files dot ‘.
’ and dot-dot ‘..
’ will be listed
first, followed by any hidden files (files starting with a dot),
followed by non-hidden files.
For ‘sort -V
’ these priorities might seem arbitrary. However,
because the sorting code is shared between the ls
and sort
program, the ordering rules are the same.