mirror of https://github.com/zulip/zulip.git
list_render: Change alphabetic sorting to be case insensitive.
The current behavior treats uppercase and lowercase characters differently resulting in incorrect sorting of lists. This change fixes that and makes the alphabetic sorting of columns case insensitive.
This commit is contained in:
parent
5be38f03db
commit
fa0a5ecb33
|
@ -295,10 +295,14 @@ var list_render = (function () {
|
||||||
// add built-in generic sort functions.
|
// add built-in generic sort functions.
|
||||||
prototype.add_generic_sort_function("alphabetic", function (prop) {
|
prototype.add_generic_sort_function("alphabetic", function (prop) {
|
||||||
return function (a, b) {
|
return function (a, b) {
|
||||||
if (a[prop] > b[prop]) {
|
// The conversion to uppercase helps make the sorting case insensitive.
|
||||||
return 1;
|
var str1 = a[prop].toUpperCase();
|
||||||
} else if (a[prop] === b[prop]) {
|
var str2 = b[prop].toUpperCase();
|
||||||
|
|
||||||
|
if (str1 === str2) {
|
||||||
return 0;
|
return 0;
|
||||||
|
} else if (str1 > str2) {
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
|
|
Loading…
Reference in New Issue