I have a file that contains two columns separated by tab.

  A10         A10_motorway_(Switzerland)              
  A-10        A-10_N/AW
  A10         A10_Networks
  A-10        A-10_road
  A10         A10_road                  
  A10_road_(California)      A10_road_(Canada)      
  A10_road_(Croatia)         A10_road_(disambiguation)  
  A10_road_(England)         A10_road_(Great_Britain)   
  A10_road_(Isle_of_Man)     A10_road_(Isle_of_Man) 
  A10_road_(Latvia)          A10_road_(Malaysia)
  A10_road_(United_Kingdom)  A10_road_(United_States_of_America)    
  A10_road_(USA)             A10_road_(Zimbabwe)
  A-10        A-10_Shrike
  A10         A10_(Switzerland)

I want to sort this file by the first column in alphabetical order. So the same titles should appear consecutively.

So I did this:

     sort -t $'\t' -k1 -d filename 

But the result is actually the snapshot above. As you see, entries "A-10" are not ordered and do not happen consecutively. I don't really care about the alphabetical order per se, but I want the same titles occurring consecutively. Could anyone explain why sort doesn't allow me to do this and how to fix this problem? Thanks!

2 Answers 2


Please try:

LC_COLLATE=C sort myfile

encountered similar behavior in the past and this one suggested by a coworker helped me


I've found empirically that -k1,1 puts the "A10"s together, and the "A-10"s together, but I don't understand why. This is with sort from GNU coreutils 8.4.

  • there's no mystery to it if you read up the sort man page
    – iruvar
    Commented Jan 15, 2016 at 2:05
  • 1
    I did. What did I miss?
    – arensb
    Commented Jan 15, 2016 at 22:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .