diff options
Diffstat (limited to 'lib/private/NaturalSort_DefaultCollator.php')
-rw-r--r-- | lib/private/NaturalSort_DefaultCollator.php | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/private/NaturalSort_DefaultCollator.php b/lib/private/NaturalSort_DefaultCollator.php new file mode 100644 index 00000000000..d688a34133a --- /dev/null +++ b/lib/private/NaturalSort_DefaultCollator.php @@ -0,0 +1,21 @@ +<?php + +/** + * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors + * SPDX-FileCopyrightText: 2016 ownCloud, Inc. + * SPDX-License-Identifier: AGPL-3.0-only + */ +namespace OC; + +class NaturalSort_DefaultCollator { + public function compare($a, $b) { + $result = strcasecmp($a, $b); + if ($result === 0) { + if ($a === $b) { + return 0; + } + return ($a > $b) ? -1 : 1; + } + return ($result < 0) ? -1 : 1; + } +} |