Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6091261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:18:26+00:00 2026-05-23T12:18:26+00:00

I use sort file ABC AB-C ABCDEFG-HI I get ABC AB-C ABCDEFG-HI why does

  • 0

I use sort file

ABC
AB-C
ABCDEFG-HI

I get

ABC
AB-C
ABCDEFG-HI

why does sort orders the string this way? how do I make it sort ‘-‘ alphabetically?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T12:18:27+00:00Added an answer on May 23, 2026 at 12:18 pm

    The solution provided by @cnicutar is correct, but the reason needs explanation which is why I’m giving a new answer.

    After the discussion with @cnicutar where in the end I suspected a bug in coreutils’ sort I found that this sorting behavior is expected:

    At that point sort appears broken because case is folded and punctuation is ignored because ‘en_US.UTF-8’ specifies this behavior.

    So to sort, your input seems to be mapped as follows:

    ABC -> ABC
    AB-C -> ABC
    ABCDEFG-HI -> ABCDEFGHI
    

    If you want pure ASCII sorting, you need to call LC_ALL=C sort (temporarily set the locale to C when calling sort which means “standard” behavior without localization; you can also use POSIX instead of C).

    On other Unixes this behavior seems to be different (tested on Mac OS X which userland tools are derived from FreeBSD), but LC_ALL=C sort should yield the same behavior across all POSIX systems.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

hello I have this code that use to sort a datatable. Dim sortingIndex As
I can't figure out what would be the best way to use Bucket Sort
I'd like to use the somelist.sort() method to do this if possible. I have
Which algorithm does the JavaScript Array#sort() function use? I understand that it can take
what's the fastest way to sort file by the first letter of each line?
I can use File('foo.bar').abspath to get the location of a file, but if I've
I'm trying to use the solution over at quirksmode.org to sort the file upload
In order to use the uniq command, you have to sort your file first.
I'd like to use some sort of stepwise rendering in a webcontrol, here is
To access the array indice at the xth position we can use some sort

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.