I was expecting @'s to be sorted together, but they interleaved with the non-@ versions. Does sort have an option for ASCII sorting? I didn't see something obvious in the man page.
$ echo '@x
> @y
> @z
> x
> y
> z' | sort
x
@x
y
@y
z
@z
I was expecting @'s to be sorted together, but they interleaved with the non-@ versions. Does sort have an option for ASCII sorting? I didn't see something obvious in the man page.
$ echo '@x
> @y
> @z
> x
> y
> z' | sort
x
@x
y
@y
z
@z
This is locale-dependent. man sort includes:
*** WARNING *** The locale specified by the environment affects sort order.
Set LC_ALL=C to get the traditional sort order that uses native byte values.
You can set that just for the one command, like:
... | LC_ALL=C sort ...
LC_COLLATE=C
which would work just as well. No need to throw the baby out with the bathwater -- an UTF-8 LC_CTYPE
is perfectly fine, it's LC_COLLATE
which is unasked for trouble.
–
Jan 29 '21 at 23:14