because they sort order is by the uid of the page without it’s path, so /zebra/alpha is before /azores
This makes a total mess of the site hierarchy and makes it very difficult to locate a specific page. Is there a way to get the query to return items sorted by their full path?
Unfortunately, the sort order (by title) is hardcoded in the Panel source code. So I’m afraid you’d have to modify it there (/panel/app/src/panel/form/fieldoptions.php).
public function items($page, $method) {
if(!$page) return new Collection();
switch($method) {
case 'visibleChildren':
$items = $page->children()->visible();
break;
case 'invisibleChildren':
$items = $page->children()->invisible();
break;
case 'siblings':
$items = $page->siblings()->not($page);
break;
case 'visibleSiblings':
$items = $page->siblings()->not($page)->visible();
break;
case 'invisibleSiblings':
$items = $page->siblings()->not($page)->invisible();
break;
case 'pages':
$items = site()->index();
$items = $items->sortBy('title', 'asc');
break;
case 'index':
$items = $page->index();
$items = $items->sortBy('title', 'asc');
break;
case 'children':
case 'grandchildren':
case 'files':
case 'images':
case 'documents':
case 'videos':
case 'audio':
case 'code':
case 'archives':
$items = $page->{$method}();
break;
default:
$items = new Collection();
}
return $items;
}
```