Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: What is the Sort Order in DOS?  (Read 4886 times)

0 Members and 1 Guest are viewing this topic.

Geek-9pm

    Topic Starter

    Mastermind
  • Geek After Dark
  • Thanked: 1026
    • Gekk9pm bnlog
  • Certifications: List
  • Computer: Specs
  • Experience: Expert
  • OS: Windows 10
What is the Sort Order in DOS?
« on: October 14, 2015, 01:39:23 PM »
I know I can sort a list with the SORT command. By I do not understand the sort order. Some characters that are late  in the ASCII table show  up early in the sort list  Where is the  order explained?  :)

BC_Programmer


    Mastermind
  • Typing is no substitute for thinking.
  • Thanked: 1140
    • Yes
    • Yes
    • BC-Programming.com
  • Certifications: List
  • Computer: Specs
  • Experience: Beginner
  • OS: Windows 11
Re: What is the Sort Order in DOS?
« Reply #1 on: October 14, 2015, 02:37:02 PM »
Do you mean actual MS-DOS/PC-DOS, or are you referring to Windows Command Prompt?

On Windows the sort order is based on the current system Locale. you can use the /l switch to change the system locale.

I'd expect MS-DOS may sort based on ASCII, since I don't think it has any locale information aside from code pages
I was trying to dereference Null Pointers before it was cool.

Geek-9pm

    Topic Starter

    Mastermind
  • Geek After Dark
  • Thanked: 1026
    • Gekk9pm bnlog
  • Certifications: List
  • Computer: Specs
  • Experience: Expert
  • OS: Windows 10
Re: What is the Sort Order in DOS?
« Reply #2 on: October 14, 2015, 04:33:50 PM »
I am using the SORT command at the command prompt.

Squashman



    Specialist
  • Thanked: 134
  • Experience: Experienced
  • OS: Other
Re: What is the Sort Order in DOS?
« Reply #3 on: October 14, 2015, 06:01:31 PM »
You should also realize that it does not sort numerically.

foxidrive



    Specialist
  • Thanked: 268
  • Experience: Experienced
  • OS: Windows 8
Re: What is the Sort Order in DOS?
« Reply #4 on: October 16, 2015, 06:38:52 AM »
I am using the SORT command at the command prompt.

But in which? MSDOS or Win9x or XP etc?

Geek-9pm

    Topic Starter

    Mastermind
  • Geek After Dark
  • Thanked: 1026
    • Gekk9pm bnlog
  • Certifications: List
  • Computer: Specs
  • Experience: Expert
  • OS: Windows 10
Re: What is the Sort Order in DOS?
« Reply #5 on: October 16, 2015, 10:08:26 AM »
OK. I was using the SORT in Windows XP.
What happens is the last  things in the ASCII table, the symbols after 'z',  end up early in the character set sort. I am in the USA.
Here are last items in the 127 ASCII set:
Quote
x
y
z
{
|
}
~
The four symbols are move up in the sort. Just ahead of the + sign.
Quote
{
|
}
~
+
<
=
>
0
1
2
Far future reference, Is there some place where on can find the sort used by a system in a specific locale?

Salmon Trout

  • Guest
Re: What is the Sort Order in DOS?
« Reply #6 on: October 16, 2015, 01:09:46 PM »
By default sort.exe sorts according the system locale. You can over ride this by using the /L [locale] switch. Currently the only locale available is the C locale which results in sorting being in binary order.

1. The test file

C:\>type test1.txt
x
y
z
{
|
}
~


2. Sort using default order

C:\>type test1.txt | sort
{
|
}
~
x
y
z


3. Sort using C locale

C:\>type test1.txt | sort /L C
x
y
z
{
|
}
~


Operating system locale charts

    IBM i5/OS
    Fedora core 6
    FreeBSD 5.4
    HP-UX 11
    SCO OpenServer 6.0.0
    SGI IRIX 6.5
    SUN OpenSolaris 2008.05
    SUN Solaris 10 Sparc
    SUN Solaris 10 x86
    Windows 2000
    Windows XP
    Windows Vista

http://collation-charts.org/


Geek-9pm

    Topic Starter

    Mastermind
  • Geek After Dark
  • Thanked: 1026
    • Gekk9pm bnlog
  • Certifications: List
  • Computer: Specs
  • Experience: Expert
  • OS: Windows 10
Re: What is the Sort Order in DOS?
« Reply #7 on: October 16, 2015, 03:11:18 PM »
Thanks for that link. I will add it to my collection.  :)
That link explains that some changes were as recent as 2007, 2009 and 2010. The changes affect both Unicode and SQL.

Interesting to learn that there  have been recently altered rules.