I have the following text file (sort_test.txt):
PGA_scaffold1__77
PGA_scaffold2__36
PGA_scaffold3__111
PGA_scaffold4__129
PGA_scaffold5__109
PGA_scaffold6__104
P
Thanks so much to @Barmar for pointing me to the Unix & Linux forum!
I managed to indirectly find the answer to my problem in this post:
Is gnu coreutils sort broken?
The solution was to change my locale!
My locale looked like this:
$ 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=
After running:
$ export LC_COLLATE=C
I was able to get my desired sorting output.