I'm using Ubuntu 16.04_xfce xenial. This more than setting the correct locale, or using "natural order" sort operands.
I sorted the apt sources file. All lines start with "#", "##", or "deb". I expected to see all blank lines, all lines with "#", then with "##", finally those starting "deb". Look about 9 lines down, then 25 lines down in my output:
root@HEJ ~ $ sort /etc/apt/sources.list
## Also, please note that software in backports WILL NOT receive any review
# deb cdrom:[Xubuntu 16.04.1 LTS _Xenial Xerus_ - Release i386 (20160719)]/ xenial main multiverse restricted univer
# deb http://archive.canonical.com/ubuntu xenial partner
deb http://archive.canonical.com/ubuntu/ xenial partner
deb http://mirror.csclub.uwaterloo.ca/debian-multimedia/ stable main
deb http://mirror.csclub.uwaterloo.ca/ubuntu/ xenial-backports main restricted universe multiverse
deb http://mirror.csclub.uwaterloo.ca/ubuntu/ xenial main restricted
deb http://mirror.csclub.uwaterloo.ca/ubuntu/ xenial multiverse
deb http://mirror.csclub.uwaterloo.ca/ubuntu/ xenial-security main restricted
deb http://mirror.csclub.uwaterloo.ca/ubuntu/ xenial-security multiverse
deb http://mirror.csclub.uwaterloo.ca/ubuntu/ xenial-security universe
deb http://mirror.csclub.uwaterloo.ca/ubuntu/ xenial universe
deb http://mirror.csclub.uwaterloo.ca/ubuntu/ xenial-updates main restricted
deb http://mirror.csclub.uwaterloo.ca/ubuntu/ xenial-updates multiverse
deb http://mirror.csclub.uwaterloo.ca/ubuntu/ xenial-updates universe
deb http://mirror.cs.pitt.edu/ubuntu/archive xenial-backports main restricted universe multiverse
deb http://mirror.cs.pitt.edu/ubuntu/archive xenial main restricted universe multiverse
deb http://mirror.cs.pitt.edu/ubuntu/archive xenial-updates main restricted universe multiverse
deb http://ppa.launchpad.net/cdemu/ppa/ubuntu xenial main
# deb http://reflection.oss.ou.edu/linuxmint/repos serena main upstream import backport
deb http://security.ubuntu.com/ubuntu/ xenial-security restricted universe multiverse main
deb http://www.4pane.co.uk/ubuntu/ xenial main
# deb-src http://archive.canonical.com/ubuntu xenial partner
# deb-src http://archive.canonical.com/ubuntu/ xenial partner
# deb-src http://mirror.csclub.uwaterloo.ca/debian-multimedia/ stable main
# deb-src http://mirror.csclub.uwaterloo.ca/debian-multimedia/ stable main
# deb-src http://mirror.cs.pitt.edu/ubuntu/archive xenial-backports main restricted universe multiverse
# deb-src http://mirror.cs.pitt.edu/ubuntu/archive xenial main restricted universe multiverse
# deb-src http://mirror.cs.pitt.edu/ubuntu/archive xenial-updates main restricted universe multiverse
# deb-src http://ppa.launchpad.net/cdemu/ppa/ubuntu xenial main
# deb-src http://reflection.oss.ou.edu/linuxmint/repos serena main upstream import backport
# deb-src http://security.ubuntu.com/ubuntu xenial-security main restricted
# deb-src http://security.ubuntu.com/ubuntu/ xenial-security main restricted universe multiverse
# deb-src http://security.ubuntu.com/ubuntu/ xenial-security main restricted universe multiverse
# deb-src http://security.ubuntu.com/ubuntu xenial-security multiverse
# deb-src http://security.ubuntu.com/ubuntu xenial-security universe
# deb-src http://us.archive.ubuntu.com/ubuntu/ xenial-backports main restricted universe multiverse
# deb-src http://us.archive.ubuntu.com/ubuntu/ xenial main restricted
# deb-src http://us.archive.ubuntu.com/ubuntu/ xenial multiverse
# deb-src http://us.archive.ubuntu.com/ubuntu/ xenial universe
# deb-src http://us.archive.ubuntu.com/ubuntu/ xenial-updates main restricted
# deb-src http://us.archive.ubuntu.com/ubuntu/ xenial-updates multiverse
# deb-src http://us.archive.ubuntu.com/ubuntu/ xenial-updates universe
# deb-src http://www.4pane.co.uk/ubuntu/ xenial main
# deb-src http://www.4pane.co.uk/ubuntu/ xenial main
# deb-src http://www.scootersoftware.com/ bcompare4 non-free
## distribution.
## extensively as that contained in the main release, although it includes
## Major bug fix updates produced after the final release of the
## multiverse WILL NOT receive any review or updates from the Ubuntu
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## N.B. software from this repository may not have been tested as
## newer versions of some applications which may provide useful features.
# newer versions of the distribution.
## or updates from the Ubuntu security team.
## 'partner' repository.
## respective vendors as a service to Ubuntu users.
## security team.
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
## team.
## team, and may not be under a free licence. Please satisfy yourself as to
## team, and may not be under a free licence. Please satisfy yourself as to
## This software is not part of Ubuntu, but is offered by Canonical and the
## Uncomment the following two lines to add software from Canonical's
## universe WILL NOT receive any review or updates from the Ubuntu security
## your rights to use the software. Also, please note that software in
## your rights to use the software. Also, please note that software in
The locale settings in effect:
root@HEJ ~ $ locale
LANG=en_US.UTF-8
LANGUAGE=en_US
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=
Research shows that I need to over-ride LC_COLLATE="en_US.UTF-8"
to LC_COLLATE="C.UTF-8"
(or better yet LC_ALL=C
) in order to get rational output. But there is one further issue here...
If this were only a question of character ordering, then all the "# " should sort together, and all the "##" sort together.
But what appears to be happening is that the "#" and "##" are removed from the sort keys, and I can't believe this a function of collation order.
What else is mucking with my sort keys?
And while we're on the subject of collation order, Where the is the binary order of characters in specific locales documented?, i.e. a human readable lists of each possible character arranged in collated order?
(A pox upon those who did not make the en_US locale definition upward compatible!)