Page 1 of 1

sort command is case insensitive...alternatives?

Posted: 17 Oct 2015 13:07
by catalinnc
hi...


on my win xp sp2 this line

Code: Select all

sort text.txt /o text.txt


makes a sorting that is case insensitive...

this is not good because i need to do a (de)dupe of the result with a case sensitive script...

content of text.txt is

Code: Select all

name1
name2
name3
NAME3
NAME2
NAME1
name3
name2
name1
NAME1
NAME2
NAME3


and the sorted text_sorted.txt is

Code: Select all

NAME1
name1
NAME1
name1
name2
NAME2
NAME2
name2
name3
NAME3
NAME3
name3


so a need a speedy alternate solution (maybe some batch with java?)


respect...
_

p.s. to be perfect clear i need a sorted result like

Code: Select all

name1
name1
NAME1
NAME1
name2
name2
NAME2
NAME2
name3
name3
NAME3
NAME3


or

Code: Select all

NAME1
NAME1
name1
name1
NAME2
NAME2
name2
name2
NAME3
NAME3
name3
name3

_

Re: sort command is case insensitive...alternatives?

Posted: 17 Oct 2015 14:54
by Aacini
Just use the undocumented /C switch:

Code: Select all

C:\> sort /C test.txt
name1
name1
NAME1
NAME1
name2
name2
NAME2
NAME2
name3
name3
NAME3
NAME3

Tested on Windows 8.1

Antonio

Re: sort command is case insensitive...alternatives?

Posted: 17 Oct 2015 15:19
by einstein1969
Nice find. Work on windows 7 too.

Einstein1969

Re: sort command is case insensitive...alternatives?

Posted: 17 Oct 2015 17:03
by npocmaka_
Aacini wrote:Just use the undocumented /C switch:
...
Antonio


Great finding :!:

The full version version of the switch is /case_sensitive

There's one more undocumented switch /u or /uni_output which will out put in unicode.

Re: sort command is case insensitive...alternatives?

Posted: 17 Oct 2015 19:06
by Aacini
Yes. Taken from sort.exe file:

Code: Select all

%s  %s case_sensitive  locale  memory  output  reverse record_maximum  temporary       uni_output  C   TEMP path   srt

Antonio

Re: sort command is case insensitive...alternatives?

Posted: 18 Oct 2015 08:47
by Samir
Neat! Anyone tested this under xp?

Re: sort command is case insensitive...alternatives?

Posted: 18 Oct 2015 08:57
by npocmaka_
Samir wrote:Neat! Anyone tested this under xp?


/c works /u does not

Re: sort command is case insensitive...alternatives?

Posted: 18 Oct 2015 11:09
by catalinnc
Aacini wrote:Just use the undocumented /C switch:

Code: Select all

C:\> sort /C test.txt
name1
name1
NAME1
NAME1
name2
name2
NAME2
NAME2
name3
name3
NAME3
NAME3

Tested on Windows 8.1

Antonio


working great on win xp sp2 too...thanks a lot...

respect...
_

Re: sort command is case insensitive...alternatives?

Posted: 21 Oct 2015 22:59
by dbenham
:shock: Whoa! I've always wanted a case sensitive sort, and the undocumented /C option has been there all along :!: :roll:

Stupid MicroSoft :evil:

Great find Aacini, thanks :D


Another option is to use my JSORT.BAT utility. If all you need is case sensitive, then SORT /C is probably your best bet. But JSORT has a number of additional features you may be interested in.


Dave Benham

Re: sort command is case insensitive...alternatives?

Posted: 22 Oct 2015 07:18
by foxidrive
dbenham wrote::shock: Whoa! I've always wanted a case sensitive sort, and the undocumented /C option has been there all along :!: :roll:

Stupid MicroSoft :evil:

Great find Aacini, thanks :D


It is a good find - but the thought that pops into my head is that the routine may not yet be robust, and is why the switch wasn't made public.

You'd think that a non-robust routine would have been removed - but we never know...

Re: sort command is case insensitive...alternatives?

Posted: 22 Oct 2015 07:31
by Squashman
Anyone got Windows 10 so they can look at the help file to see if they added it.

Re: sort command is case insensitive...alternatives?

Posted: 22 Oct 2015 07:44
by npocmaka_
Squashman wrote:Anyone got Windows 10 so they can look at the help file to see if they added it.


It's not added in the help.
That's why I looked at sort.exe with strings.exe to see if there's something else undocumented.

Re: sort command is case insensitive...alternatives?

Posted: 22 Oct 2015 08:59
by Samir
Anyone want to stress test the undocumented switch? That should give us some idea if it's faulty, and if so, where.