A command to sort stdin in ASCII order

Sometimes, GNU sort does not behave as expected. Here's an example:

> bind | sort

(This assumes you're using fish. In bash, the equivalent is bind -p.) All of the non-alpha characters in the output are basically ignored in the sorting, undermining the intention. Here's a sample of the output:

bind --preset \e\b backward-kill-word
bind --preset \eb backward-word
bind --preset \e\[B down-or-search
bind --preset \e\< beginning-of-buffer
bind --preset \e cancel
bind --preset \ec capitalize-word
bind --preset \e\[C forward-char
bind --preset \e\[D backward-char
bind --preset \ed kill-word

What I wanted was to put all \e[a-z] keybindings next to each other. How do I change sort's behaviour to sort strictly in ASCII order, treating all characters the same as letters? I've looked in the man page and haven't found anything useful.


You're right, perfectly random stranger. There is no option for this in sort's commandline switches. But sort can be made to behave this way. All you have to do is change the locale:

> bind | LANG=C sort
...
bind --preset \e\x7f backward-kill-word
bind --preset \eb backward-word
bind --preset \ec capitalize-word
bind --preset \ed kill-word
bind --preset \ee edit_command_buffer
bind --preset \ef forward-word
bind --preset \eh __fish_man_page
bind --preset \el __fish_list_current_token
...