Collection sorting


I’m attempting to sort a collection, using the following:

{% set collection = page.collection().sort(title, asc) %}

However this doesn’t seem to work. If I drop the “sort” method the collection works. What am I doing wrong? Thanks.

if your page has children, then you can call sort on the page directly, eg page.sort. There is no sort method on the Collection object itself:

If you want to sort on all pages however, you can do that with pages.sort,

Or like in the learn example, you can dynamically create a new collection based on taxonomy and also set the sort order:

{% set progress = page.collection({'items':{'@taxonomy.category': 'docs'},'order': {'by': 'default', 'dir': 'asc'}}) %}

Hope that helps…

Thanks, that clears up the confusion.