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:
vinitS101 2019-04-13 01:08:03 +05:30 committed by Tim Abbott
parent 5be38f03db
commit fa0a5ecb33
1 changed files with 7 additions and 3 deletions

View File

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