Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
deleted 35 characters in body
Source Link
ctx
  • 2.9k
  • 13
  • 19

This shows the other point inAccording to the comment of Stéphane Chazelas you are sorting the wohle line and not only the first field. With LC_ALL=C , sorts before c:

% LC_ALL=en_US.utf8 sort -t, -k1,1  test --debug 
sort: text ordering performed using ‘en_US.utf8’ sorting rules
a,foo
_
_____
ant,baz
___
_______
b,foo
_
_____
bc,pe
__
_____
bcd,ty
___
______
c,bar
_
_____
cn,cn
__
_____
% LC_ALL=en_US.utf8 sort -t, -k1  test --debug 
sort: text ordering performed using ‘en_US.utf8’ sorting rules
a,foo
_____
_____
ant,baz
_______
_______
bcd,ty
______
______
bc,pe
_____
_____
b,foo
_____
_____
c,bar
_____
_____
cn,cn
_____
_____

If you do this with LC_ALL=C and -k1 you can see that you still sort the whole line and not the first field.

This shows the other point in the comment of Stéphane Chazelas:

% LC_ALL=en_US.utf8 sort -t, -k1,1  test --debug 
sort: text ordering performed using ‘en_US.utf8’ sorting rules
a,foo
_
_____
ant,baz
___
_______
b,foo
_
_____
bc,pe
__
_____
bcd,ty
___
______
c,bar
_
_____
cn,cn
__
_____
% LC_ALL=en_US.utf8 sort -t, -k1  test --debug 
sort: text ordering performed using ‘en_US.utf8’ sorting rules
a,foo
_____
_____
ant,baz
_______
_______
bcd,ty
______
______
bc,pe
_____
_____
b,foo
_____
_____
c,bar
_____
_____
cn,cn
_____
_____

If you do this with LC_ALL=C and -k1 you can see that you still sort the whole line and not the first field.

According to the comment of Stéphane Chazelas you are sorting the wohle line and not only the first field. With LC_ALL=C , sorts before c:

% LC_ALL=en_US.utf8 sort -t, -k1,1  test --debug 
sort: text ordering performed using ‘en_US.utf8’ sorting rules
a,foo
_
_____
ant,baz
___
_______
b,foo
_
_____
bc,pe
__
_____
bcd,ty
___
______
c,bar
_
_____
cn,cn
__
_____
% LC_ALL=en_US.utf8 sort -t, -k1  test --debug 
sort: text ordering performed using ‘en_US.utf8’ sorting rules
a,foo
_____
_____
ant,baz
_______
_______
bcd,ty
______
______
bc,pe
_____
_____
b,foo
_____
_____
c,bar
_____
_____
cn,cn
_____
_____

Source Link
ctx
  • 2.9k
  • 13
  • 19

This shows the other point in the comment of Stéphane Chazelas:

% LC_ALL=en_US.utf8 sort -t, -k1,1  test --debug 
sort: text ordering performed using ‘en_US.utf8’ sorting rules
a,foo
_
_____
ant,baz
___
_______
b,foo
_
_____
bc,pe
__
_____
bcd,ty
___
______
c,bar
_
_____
cn,cn
__
_____
% LC_ALL=en_US.utf8 sort -t, -k1  test --debug 
sort: text ordering performed using ‘en_US.utf8’ sorting rules
a,foo
_____
_____
ant,baz
_______
_______
bcd,ty
______
______
bc,pe
_____
_____
b,foo
_____
_____
c,bar
_____
_____
cn,cn
_____
_____

If you do this with LC_ALL=C and -k1 you can see that you still sort the whole line and not the first field.