JSORT.BAT v4.2 - Case sensitive sort with option for numeric sort

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
goldfish
Posts: 10
Joined: 31 Mar 2014 07:02

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

#16 Post by goldfish » 07 Nov 2014 02:10

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..

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

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

#17 Post by foxidrive » 07 Nov 2014 04:33

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.

Squashman
Expert
Posts: 4486
Joined: 23 Dec 2011 13:59

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

#18 Post by Squashman » 07 Nov 2014 08:19

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.

goldfish
Posts: 10
Joined: 31 Mar 2014 07:02

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

#19 Post by goldfish » 07 Nov 2014 08:39

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

Squashman
Expert
Posts: 4486
Joined: 23 Dec 2011 13:59

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

#20 Post by Squashman » 07 Nov 2014 08:47

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.

goldfish
Posts: 10
Joined: 31 Mar 2014 07:02

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

#21 Post by goldfish » 07 Nov 2014 09:15

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.

Squashman
Expert
Posts: 4486
Joined: 23 Dec 2011 13:59

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

#22 Post by Squashman » 07 Nov 2014 09:29

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

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

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

#23 Post by foxidrive » 07 Nov 2014 09:33

Squashman wrote:Hi Brian.



Bingo.

goldfish
Posts: 10
Joined: 31 Mar 2014 07:02

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

#24 Post by goldfish » 07 Nov 2014 18:58

foxidrive wrote:
Squashman wrote:Hi Brian.



Bingo.

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

goldfish
Posts: 10
Joined: 31 Mar 2014 07:02

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

#25 Post by goldfish » 07 Nov 2014 19:00

Remove that hybrid and do everything in jscript or vbscript. running in one process is better than spawning different processes.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

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

#26 Post by foxidrive » 05 Jan 2015 06:54

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.

dbenham
Expert
Posts: 2461
Joined: 12 Feb 2011 21:02
Location: United States (east coast)

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

#27 Post by dbenham » 05 Jan 2015 09:53

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

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

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

#28 Post by foxidrive » 05 Jan 2015 12:10

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.

Compo
Posts: 600
Joined: 21 Mar 2014 08:50

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

#29 Post by Compo » 05 Jan 2015 12:56

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

dbenham
Expert
Posts: 2461
Joined: 12 Feb 2011 21:02
Location: United States (east coast)

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

#30 Post by dbenham » 05 Jan 2015 14:27

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

Post Reply