3D Clipboard

A place to discuss 3D Clipboard

Sort - case insensitive

Share actions you've created here.
Bill
Posts: 4
Joined: Tue Mar 19, 2013 4:52 pm

Sort - case insensitive

Postby Bill » Sun May 08, 2016 4:53 pm

I've used Vince' sort routine a lot in the past. Lately however, I've had a lot of mixed case text that needed to be sorted without regard to case. Not being a Jscript guru, I did a bit of surfing and found an "almost" one-liner posted by Ivan Krechetov at the StackOverflow.com site. I combined Vince' and Ivan's code and got my solution. I haven't done a lot of testing but it has done the job for me so far.
Please note that the code is Jscript NOT VBscript.

Code: Select all

//   Action: CIsort  (Case Insensitive sort)
//   Author: Bill King
//   Date:   05-07-16
//   Code:   Jscript
// 
//   This is a case insensitive sort.
//   It is a modification of Vince' original post on 7/22/11
//   The use of sort(function) was devised by Ivan Krechetov at the StackOverflow site.
// 
Clipboard.value = Clipboard.value
   .split("\r\n")
   .sort(function (a, b) {
    return a.toLowerCase().localeCompare(b.toLowerCase())
    })
   .join("\r\n");
 

Return to “Actions”

 

 

cron