Thursday, 20 August 2015

Javascript / AngularJs orderBy Wrong order for Ukrainian і


Today i face to problem when angular orderBy sort incorrectly Ukrainian names. So when i order by

ng-repeat="dancer in dancers | filter: filterDancers(criteria) | orderBy: 'FullName'"

And result is incorrect
Then i found that issue is in javascript sort which could be easily fixed by adding custom filter

app.filter('orderByCustom', function () {

    return function (items) {

        return items.sort(function (a, b) { return a.FullName.localeCompare(b.FullName) });;

    };

});


then html

ng-repeat="dancer in dancers | filter: filterDancers(criteria) | orderByCustom"


And now it works

Volodymyr Bilyachat Web Developer