Menu

sort and upper/lowercase characters

Help
2006-06-09
2012-07-26
  • Nobody/Anonymous

    Can sort be made to treat case as significant during sorting?
    Having tried every possible command line option and tried various LC_ALL values, I cannot seem to enable this.

    When sorting the following :
    a
    A
    b
    B
    X
    x
    Z
    z

    the output obtained is :
    a
    A
    b
    B
    x
    X
    z
    Z

    I would have thought a case sensitive sort should produce the following output :
    A
    B
    X
    Z
    a
    b
    x
    z

    Does sort have an option to allow case sensitive sorting ?

     
    • GnuWin

      GnuWin - 2006-06-10

      The -f (--ignore-case) option lets sort treat lowercase the same as uppercase. BTW, sort --help gives a summary of all options.

       
    • Keith Marshall

      Keith Marshall - 2006-06-12

      But the OP is saying that he/she gets the --ignore-case behaviour, even when this flag is not specified.

      The actual locale involved isn't specified, but with "English_United Kingdom.1252", the sort command in my MSYS installation, (see www.mingw.org/MinGWiki/index.php/FAQ), behaves precisely as the OP expected.

      Setting "LC_ALL", or any of the "LC_..." category variables, or "LANG", is a waste of time on Windoze, for Microsoft's [POSIXly broken] setlocale implementation doesn't respect the process environment settings, and worse still, doesn't respect ISO-639 language codes. (I'm currently developing a MinGW workaround for this).

       
MongoDB Logo MongoDB