1.

Solve : What is the Sort Order in DOS??

Answer»

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?
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 pagesI am using the SORT command at the command prompt.You should also realize that it does not sort numerically.Quote from: Geek-9pm on October 14, 2015, 04:33:50 PM

I am using the SORT command at the command prompt.

But in which? MSDOS or Win9x or XP etc?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?
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/

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.



Discussion

No Comment Found