mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-04 02:57:38 +00:00
make cookiemanager sort strings case-insensitively.
thanks to smanux@lfjr.net for the patch. r=dwitte, sr=darin, b=220067
This commit is contained in:
parent
189bbda3e5
commit
e7d5f11d73
@ -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;
|
||||
}
|
||||
|
@ -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…
Reference in New Issue
Block a user