summaryrefslogtreecommitdiffstats
path: root/lib/private/naturalsort_defaultcollator.php
blob: 63136aac74938f8485e62b8f939c5ffd35ee60ec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?php
/**
 * Copyright (c) 2014 Vincent Petry <PVince81@owncloud.com>
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 * See the COPYING-README file.
 *
 */

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;
	}
}