orderBy case sensitiv

Sep 24, 2012 at 6:57 AM

Hi,

im using last v3 beta, and got a problem, when im trying to sort mine data it sorts with case sensitive is there a way to change it?

because now after sort i got something like this:

123
Apple
Banana
Ziggy
circle
smile

its just an example 

Coordinator
Sep 24, 2012 at 6:32 PM
Edited Sep 24, 2012 at 6:48 PM

It was proposed, but I've forgotten.
http://linqjs.codeplex.com/workitem/5139

Sorry, I'll fix next release.
Maybe it has following api.

var charCodeComparer = function (str1, str2) {
    if (typeof str1 !== "string") str1 = str1.toString();
    if (typeof str2 !== "string") str2 = str2.toString();

    for (var i = 0; i < str1.length; i++) {
        var c1 = str1.charCodeAt(i);
        var c2 = str2.charCodeAt(i);

        if (c1 === c2) continue;
        else if (c1 > c2) return 1;
        else return -1;
    }
    return (str1.length === str2.length) ? 0
         : (str1.length > str2.length) ? 1
         : -1;
}

var array = ["Banana", "Ziggy", 123, "circle", "Apple", "smile"];

var sortedArray = Enumerable.from(array).orderBy("", charCodeComparer).toArray();
Nov 8, 2012 at 2:48 AM

Are you using an alpha build because the current downloadable one or the beta doesn't support custom compare's.

Coordinator
Nov 8, 2012 at 3:07 AM

Yes, ver.3.0.3-Beta4 doesn't have this api.
I'll add next(Beta5) version.

sorry and wait a moment please.

Nov 8, 2012 at 3:14 AM

I notice there are a lot of breaking changes with v3, like the caseings is different. You should Change the Enumerable object to Enumerable3 or something. So that people can use both libraries in the same project since in large projects it might take time to switch over to v3.