orderBy case sensitiv

Sep 24, 2012 at 7:57 AM


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:


its just an example 

Sep 24, 2012 at 7:32 PM
Edited Sep 24, 2012 at 7:48 PM

It was proposed, but I've forgotten.

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 3:48 AM

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

Nov 8, 2012 at 4: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 4: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.