Fix error in sorting a searched list by an inherent value

This commit is contained in:
Joshua Ramon Enslin 2021-09-26 19:25:07 +02:00
parent d35e3ed003
commit a1e6d7773b
Signed by: jrenslin
GPG Key ID: 46016F84501B70AE

View File

@ -29,8 +29,14 @@ final class MD_STD_SORT {
if ($a[$nameIndex] === $searchValue) return -1; if ($a[$nameIndex] === $searchValue) return -1;
if ($b[$nameIndex] === $searchValue) return 1; if ($b[$nameIndex] === $searchValue) return 1;
if (stripos($a[$nameIndex], $searchValue) !== false) return -1; $containsSearchA = stripos($a[$nameIndex], $searchValue);
if (stripos($b[$nameIndex], $searchValue) !== false) return 1; $containsSearchB = stripos($b[$nameIndex], $searchValue);
if ($containsSearchA !== false and $containsSearchB !== false) {
return $a[$sortIndex] > $b[$sortIndex] ? -1 : 1;
}
if ($containsSearchA !== false) return -1;
if ($containsSearchB !== false) return 1;
return $a[$sortIndex] > $b[$sortIndex] ? -1 : 1; return $a[$sortIndex] > $b[$sortIndex] ? -1 : 1;
}; };