Skip to content

Commit

Permalink
case-insensitive sorting of string values - refs BT#16818
Browse files Browse the repository at this point in the history
  • Loading branch information
Sébastien Ducoulombier committed Apr 14, 2020
1 parent 6888918 commit 78b5a29
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion main/inc/lib/CoursesAndSessionsCatalog.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,12 @@ public static function searchAndSortCourses(
$valueA = array_key_exists($key, $a) ? $a[$key] : null;
$valueB = array_key_exists($key, $b) ? $b[$key] : null;
if ($valueA !== $valueB) {
return ($valueA < $valueB ? -1 : 1) * (in_array($key, $descKeys) ? -1 : 1);
$aIsLessThanB = (is_string($valueA) && is_string($valueB))
? strtolower($valueA) < strtolower($valueB)
: $valueA < $valueB;
$reverseOrder = in_array($key, $descKeys);
$aIsBeforeB = ($aIsLessThanB xor $reverseOrder);
return $aIsBeforeB ? -1 : 1;
}
}
return 0;
Expand Down

0 comments on commit 78b5a29

Please sign in to comment.