Sort - case insensitive

Share actions you've created here.
Post Reply
Posts: 4
Joined: Tue Mar 19, 2013 9:52 am

Sort - case insensitive

Post by Bill » Sun May 08, 2016 9:53 am

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 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
   .sort(function (a, b) {
    return a.toLowerCase().localeCompare(b.toLowerCase())

Post Reply