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:
dwitte%stanford.edu 2003-10-15 09:41:40 +00:00
parent 189bbda3e5
commit e7d5f11d73
2 changed files with 42 additions and 20 deletions

View File

@ -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;
}

View File

@ -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;
}