Bugzilla will be upgraded to version 5.0 on a still to be determined date in the near future. The original upgrade date has been delayed.
Bug 151959 - ls | sort gives wrong order
ls | sort gives wrong order
Product: Red Hat Enterprise Linux 4
Classification: Red Hat
Component: coreutils (Show other bugs)
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Tim Waugh
Depends On:
  Show dependency treegraph
Reported: 2005-03-23 15:49 EST by joseph
Modified: 2007-11-30 17:07 EST (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2005-03-24 06:21:36 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description joseph 2005-03-23 15:49:13 EST
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4.2) Gecko/20040308

Description of problem:
when I use ls and sort commnd, It does not give the correct order. e.g. I have directory called temp, under temp, I created the following files:
Avoid  BolusPTV  CTV_CT  GTV_CT  markers  PTV_CT  skin. I use the touch command. then I issue the command ls | sort, it give me the results as "Avoid  BolusPTV  CTV_CT  GTV_CT  markers  PTV_CT  skin". The "markers" shall be after the "PTV_CT". This is a error or a bug

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
1.mkdir temp
2. touch Avoid  BolusPTV  CTV_CT  GTV_CT  markers  PTV_CT  skin
3. ls | sort

Actual Results:  Avoid  BolusPTV  CTV_CT  GTV_CT  markers  PTV_CT  skin

Expected Results:  Avoid  BolusPTV  CTV_CT  GTV_CT PTV_CT  markers skin

Additional info:
Comment 1 Tim Waugh 2005-03-24 06:21:36 EST
You don't say what locale you are using, but presumably it is not the C locale
(which *would* give the order you cite).

To get the order you want, use:

ls | LC_COLLATE=C sort

ISO 14651, which is the sorting standard, specifies this behaviour.  You can
also find some information in the strcoll documentation.

IEEE Std 1003.1, 2003 Edition, says that the sorting "shall be performed
using the collating sequence of the current locale".

Note You need to log in before you can comment on or make changes to this bug.