1
0
mirror of https://github.com/misterunknown/ifm.git synced 2025-08-12 19:13:57 +02:00

sort files and dirs w/ natural sorting

This commit is contained in:
Dmitriy Novash
2022-05-24 17:40:27 +03:00
parent 6226f8a16c
commit 5d06965823

View File

@@ -340,8 +340,8 @@ f00bar;
}
closedir($handle);
}
usort($dirs, [$this, "sortByName"]);
usort($files, [$this, "sortByName"]);
array_multisort(array_column($dirs, 'name'), SORT_ASC, SORT_NATURAL | SORT_FLAG_CASE, $dirs);
array_multisort(array_column($files, 'name'), SORT_ASC, SORT_NATURAL | SORT_FLAG_CASE, $files);
return array_merge($dirs, $files);
}
@@ -1283,13 +1283,6 @@ f00bar;
return true;
}
// sorting function for file and dir arrays
private function sortByName($a, $b) {
if (strtolower($a['name']) == strtolower($b['name']))
return 0;
return (strtolower($a['name']) < strtolower($b['name'])) ? -1 : 1;
}
// is cURL extention avaliable?
private function checkCurl() {
if (!function_exists("curl_init")