JSFiddle - React, Tailwind, and code Playground

by billybraga

HTML

<html>
    <body>
    </body>
</html>

JavaScript

function createComparator(c,i) {
    return function (a, b) {
        alert(a[c] + " - " + b[c] + " = " + (a[c].toString().localeCompare(b[c])));
        return i*(a[c].toString().localeCompare(b[c]));
    };
}

var a = [{
    test: "Ă lo",
    test1: "zalo"
},{
    test: "zbonjour",
    test1: "bonjour"
}];

a.sort(createComparator("test",1));

$("body").html(JSON.stringify(a, null, 4).replace(/ /g, "&nbsp").replace(/\n/g, "<br />"));