From 287a51148a3cdc74d70f6dd9e1de0c3d336b8fae Mon Sep 17 00:00:00 2001 From: Djamil Legato Date: Tue, 11 Jul 2017 17:01:13 -0700 Subject: [PATCH] Fix natural sort when > 100 pages (#1564) * Fix natural sort when > 100 pages * Revert manual and default sort type * Only check prefix numbers --- system/src/Grav/Common/Page/Pages.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/system/src/Grav/Common/Page/Pages.php b/system/src/Grav/Common/Page/Pages.php index ffb280f9d..3d9762684 100644 --- a/system/src/Grav/Common/Page/Pages.php +++ b/system/src/Grav/Common/Page/Pages.php @@ -1257,6 +1257,12 @@ class Pages $locale = setlocale(LC_COLLATE, 0); //`setlocale` with a 0 param returns the current locale set $col = Collator::create($locale); if ($col) { + if (($sort_flags & SORT_NATURAL) === SORT_NATURAL) { + $list = preg_replace_callback('~([0-9]+)\.~', function($number) { + return sprintf('%032d', $number); + }, $list); + } + $col->asort($list, $sort_flags); } else { asort($list, $sort_flags);