Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

feat(orderBy): support sorting of umlauts #5123

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/ng/filter/orderBy.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,11 @@ function orderByFilter($parse){
var t2 = typeof v2;
if (t1 == t2) {
if (t1 == "string") {
v1 = v1.toLowerCase();
v2 = v2.toLowerCase();
v1 = v1.toLowerCase();
v2 = v2.toLowerCase();
if (typeof v1.localeCompare == 'function') {
return v1.localeCompare(v2);
}
}
if (v1 === v2) return 0;
return v1 < v2 ? -1 : 1;
Expand Down
4 changes: 4 additions & 0 deletions test/ng/filter/orderBySpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ describe('Filter: orderBy', function() {
expect(orderBy([{a:15, b:1}, {a:2, b:1}], ['+b', '-a'])).toEqualData([{a:15, b:1}, {a:2, b:1}]);
});

it('should sort strings via localeCompare', function() {
expect(orderBy([{a:'ö'},{a:'a'},{a:'z'}], 'a')).toEqualData([{a:'a'},{a:'ö'},{a:'z'}]);
});

it('should use function', function() {
expect(
orderBy(
Expand Down