зеркало из https://github.com/mozilla/gecko-dev.git
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:
Родитель
189bbda3e5
Коммит
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;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче