The Linux sort command can arrange command output or file content in a lot more ways than you might realize–alphabetically, numerically, by month and randomly are only some of the more interesting choices. In this post, we take a look at some of the more useful sorting options and explain how they differ.
The default
The default sort might seem fairly straightforward. Digits come first, followed by letters and, for each letter, lowercase characters precede uppercase characters. You can expect to see this kind of ordering:
012345aAbBcCdDeE
ASCII order
Looking at the numeric byte values for each of these letters, you may note that what you see above is not the “natural order” as far as ASCII is concerned.