Skip to content

Commit

Permalink
Use natural sorting instead of string comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
HLeithner committed Apr 23, 2024
1 parent 755588b commit 4edaa4c
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ public function getDirectoryTree($dir)
uksort($result, function ($a, $b) use ($result) {
if (\is_string($a)) {
if (\is_string($b)) {
return $a <=> $b;
return strnatcmp($a, $b);
}

return -1;
Expand All @@ -453,7 +453,7 @@ public function getDirectoryTree($dir)
return 1;
}

return $result[$a]->name <=> $result[$b]->name;
return strnatcmp($result[$a]->name, $result[$b]->name);
});

return !empty($result) ? $result : ['.'];
Expand Down

0 comments on commit 4edaa4c

Please sign in to comment.