NaturalSort_DefaultCollator.php 435 B

123456789101112131415161718192021
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
  5. * SPDX-License-Identifier: AGPL-3.0-only
  6. */
  7. namespace OC;
  8. class NaturalSort_DefaultCollator {
  9. public function compare($a, $b) {
  10. $result = strcasecmp($a, $b);
  11. if ($result === 0) {
  12. if ($a === $b) {
  13. return 0;
  14. }
  15. return ($a > $b) ? -1 : 1;
  16. }
  17. return ($result < 0) ? -1 : 1;
  18. }
  19. }