Page 2 of 4

Re: JSORT.BAT - Case sensitive sort with option for numeric

Posted: 07 Nov 2014 02:10
by goldfish
applaud your effort in creating a "native" solution to sort, however, a compiled tool is always "faster" than a script engine. There's a GNU win32 sort in http://gnuwin32.sourceforge.net/packages/coreutils.htm, also, windows have sort as well..

Re: JSORT.BAT - Case sensitive sort with option for numeric

Posted: 07 Nov 2014 04:33
by foxidrive
goldfish wrote:applaud your effort in creating a "native" solution to sort,

Yes, it's very useful with the various options, and especially for people that cannot install third party tools due to policies.
however, a compiled tool is always "faster" than a script engine. There's a GNU win32 sort in http://gnuwin32.sourceforge.net/packages/coreutils.htm, also, windows have sort as well..

Dave's tool can also do things that Windows sort is unable to do.

Re: JSORT.BAT - Case sensitive sort with option for numeric

Posted: 07 Nov 2014 08:19
by Squashman
goldfish wrote:applaud your effort in creating a "native" solution to sort, however, a compiled tool is always "faster" than a script engine. There's a GNU win32 sort in http://gnuwin32.sourceforge.net/packages/coreutils.htm, also, windows have sort as well..

There are always reasons why people write the scripts that they do. It wasn't about speed. It was about functionality. If you read Dave's original post I think he explains that very well.

Hi Brian.

Re: JSORT.BAT - Case sensitive sort with option for numeric

Posted: 07 Nov 2014 08:39
by goldfish
Not forgetting that modern Windows also comes with Powershell installed by default. I am sure one could also use that power for sorting. http://technet.microsoft.com/en-us/libr ... 76968.aspx

Re: JSORT.BAT - Case sensitive sort with option for numeric

Posted: 07 Nov 2014 08:47
by Squashman
goldfish wrote:Not forgetting that modern Windows also comes with Powershell installed by default. I am sure one could also use that power for sorting. http://technet.microsoft.com/en-us/libr ... 76968.aspx

The other main point of JSORT is that it is a hybrid BATCH/Jscript. Hard to do that with powershell. There is a running thread about that topic.

Re: JSORT.BAT - Case sensitive sort with option for numeric

Posted: 07 Nov 2014 09:15
by goldfish
Squashman wrote:
goldfish wrote:Not forgetting that modern Windows also comes with Powershell installed by default. I am sure one could also use that power for sorting. http://technet.microsoft.com/en-us/libr ... 76968.aspx

The other main point of JSORT is that it is a hybrid BATCH/Jscript. Hard to do that with powershell. There is a running thread about that topic.

Why would powershell need a hybrid? I don't understand.

Re: JSORT.BAT - Case sensitive sort with option for numeric

Posted: 07 Nov 2014 09:29
by Squashman
goldfish wrote:Why would powershell need a hybrid? I don't understand.

Please ask that question in this thread.
viewtopic.php?f=3&t=5543
Or this thread.
viewtopic.php?f=3&t=5526

Re: JSORT.BAT - Case sensitive sort with option for numeric

Posted: 07 Nov 2014 09:33
by foxidrive
Squashman wrote:Hi Brian.



Bingo.

Re: JSORT.BAT - Case sensitive sort with option for numeric

Posted: 07 Nov 2014 18:58
by goldfish
foxidrive wrote:
Squashman wrote:Hi Brian.



Bingo.

what's up long time no see hope you missed me.

Re: JSORT.BAT - Case sensitive sort with option for numeric

Posted: 07 Nov 2014 19:00
by goldfish
Remove that hybrid and do everything in jscript or vbscript. running in one process is better than spawning different processes.

Re: JSORT.BAT - Case sensitive sort with option for numeric

Posted: 05 Jan 2015 06:54
by foxidrive
Dave, given data like this:

Code: Select all

Cat on a hot tin roof (2003).txt
101 (nutty) dalmations (1996).txt
Short Circuit (1999).txt


Can jsort use a negative token so that the names can be sorted by the date terms and it returns this?

Code: Select all

101 (nutty) dalmations (1996).txt
Short Circuit (1999).txt
Cat on a hot tin roof (2003).txt


I haven't looked at the code to see how you've implemented it - thought you might like the idea to add to Jsort.

Re: JSORT.BAT - Case sensitive sort with option for numeric

Posted: 05 Jan 2015 09:53
by dbenham
Good idea - I may implement that feature in the near future.

But until then, you can still easily get your desired result if you preprocess the text with JREPL to encode all token delimiters except for the last one, do the sort, and then use JREPL to decode the original delimiters:

Code: Select all

jrepl "\\ \((?=.*\()" "\s \p" /t " " /f test.txt | jsort /d "(" /t 2 | jrepl "\\s \\p" "\ (" /t " "


Dave Benham

Re: JSORT.BAT - Case sensitive sort with option for numeric

Posted: 05 Jan 2015 12:10
by foxidrive
Much appreciated Dave!

After checking what each segment does I'm a little curious why the slashes were encoded.

There's an anomaly though too - can you see why these items sorted in this way?

Code: Select all

Alpha and Omega (2010).aaa
A-Team, The (2010).mmm
Alice in Wonderland (2010).mmm
Alien Raiders (2010).mmm
All Good Things (2010).mmm
Arctic Predator (2010).mmm


The alpha sort at the beginning of the line isn't quite right, but it does do an admirable job and is fine for what I need it for.

I changed the extensions to keep it more low key, but they are avi and mkv and the first character is correct.

Re: JSORT.BAT - Case sensitive sort with option for numeric

Posted: 05 Jan 2015 12:56
by Compo
foxidrive wrote:There's an anomaly though too - can you see why these items sorted in this way?

Code: Select all

Alpha and Omega (2010).aaa
A-Team, The (2010).mmm
Alice in Wonderland (2010).mmm
Alien Raiders (2010).mmm
All Good Things (2010).mmm
Arctic Predator (2010).mmm


The alpha sort at the beginning of the line isn't quite right, but it does do an admirable job and is fine for what I need it for.

My suggestion is it's sorting priorities are year, alphabet extension, alphabet name

Re: JSORT.BAT - Case sensitive sort with option for numeric

Posted: 05 Jan 2015 14:27
by dbenham
foxidrive wrote:After checking what each segment does I'm a little curious why the slashes were encoded.
Just in case the source file alredy contains slashes. I know they are not present in your example, but it could happen, especially if your file contains full paths instead of just file names.


foxidrive wrote:There's an anomaly though too - can you see why these items sorted in this way?

Code: Select all

Alpha and Omega (2010).aaa
A-Team, The (2010).mmm
Alice in Wonderland (2010).mmm
Alien Raiders (2010).mmm
All Good Things (2010).mmm
Arctic Predator (2010).mmm


The alpha sort at the beginning of the line isn't quite right, but it does do an admirable job and is fine for what I need it for.

I changed the extensions to keep it more low key, but they are avi and mkv and the first character is correct.
:?: :?
I don't see the problem. The /T option does not specify that only one token is sorted. It simply is part of the equation that determines the beginning position that is used for sorting. Each line is sorted based on the year through the end of the line. The content before the year is simply ignored. Of course (2010).aaa sorts before (2010).mmm. But all files that end with (2010).mmm are ties and the order for them is undefined.

I briefly toyed with the idea of adding a feature where JSORT could parse each line into multiple fields, and then you could specify the sort order and precedence for each field individually. But I quickly abandoned that line of thought and opted to keep it simple.


Dave Benham