diff options
author | Vincent Petry <pvince81@owncloud.com> | 2014-02-18 12:29:05 +0100 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2014-08-11 13:28:53 +0200 |
commit | 173059f6d00faa06dab9188efb2d7536f15861e4 (patch) | |
tree | 2d3efee8b0e682b16d33fb8a37e7f5567b696800 /lib/public/util.php | |
parent | 86ae3bd1e7d20e4f28ea9d7b9f71f1fdef0087aa (diff) | |
download | nextcloud-server-173059f6d00faa06dab9188efb2d7536f15861e4.tar.gz nextcloud-server-173059f6d00faa06dab9188efb2d7536f15861e4.zip |
Fixed file list sorting
Now using a natural sort algorithm that is more consistent between JS
and PHP (although not perfect in some corner cases)
- added OC.Util.naturalSortComparator that uses the same algo that was
used for the user list
- changed user list and files list to use OC.Util.naturalSortComparator
- removed toLowerCase() and changed the comparator to use
String.localeCompare()
- added unit tests
- added OC_NaturalSort that is used by OCP\Util::naturalSortCompare()
Diffstat (limited to 'lib/public/util.php')
-rw-r--r-- | lib/public/util.php | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/public/util.php b/lib/public/util.php index 87b7a4f19db..5d63cf3ffbc 100644 --- a/lib/public/util.php +++ b/lib/public/util.php @@ -511,6 +511,17 @@ class Util { } /** + * Compare two strings to provide a natural sort + * @param $a first string to compare + * @param $b second string to compare + * @return -1 if $b comes before $a, 1 if $a comes before $b + * or 0 if the strings are identical + */ + public static function naturalSortCompare($a, $b) { + return \OC\NaturalSort::getInstance()->compare($a, $b); + } + + /** * check if a password is required for each public link * @return boolean */ |