mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-31 19:10:36 +00:00
port fix to sort strings case-insensitively, bug 220067
This commit is contained in:
parent
ddd4f28a33
commit
0e97dcab55
@ -126,19 +126,11 @@ function SortTree(tree, view, table, column, lastSortColumn, lastSortAscending,
|
||||
var compareFunc;
|
||||
if (ascending) {
|
||||
compareFunc = function compare(first, second) {
|
||||
if (first[column] < second[column])
|
||||
return -1;
|
||||
if (first[column] > second[column])
|
||||
return 1;
|
||||
return 0;
|
||||
return CompareLowerCase(first[column], second[column]);
|
||||
}
|
||||
} else {
|
||||
compareFunc = function compare(first, second) {
|
||||
if (first[column] < second[column])
|
||||
return 1;
|
||||
if (first[column] > second[column])
|
||||
return -1;
|
||||
return 0;
|
||||
return CompareLowerCase(second[column], first[column]);
|
||||
}
|
||||
}
|
||||
table.sort(compareFunc);
|
||||
@ -166,3 +158,22 @@ function SortTree(tree, view, table, column, lastSortColumn, lastSortAscending,
|
||||
|
||||
return ascending;
|
||||
}
|
||||
|
||||
/**
|
||||
* Case insensitive string comparator.
|
||||
*/
|
||||
function CompareLowerCase(first, second) {
|
||||
|
||||
var firstLower = first.toLowerCase();
|
||||
var secondLower = second.toLowerCase();
|
||||
|
||||
if (firstLower < secondLower) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (firstLower > secondLower) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user