Order entries based on last string of title I would like to get the last string of a entry title and order entries based on that. Basically the people title are their full names and I am trying to find their last name and filter based on that, instead of their first name.

{% set entries = craft.entries.section('people').order('title').limit(0) %}

similar to this entry.title|split(' ')|last
Another option is to use the Preparse plugin to automatically parse out and store last names in a hidden field.


Install the Preparse plugin
Create a new “Last Name” field using the Preparse field type
Set the field’s Twig template setting to this:

{{ entry.title|split(' ')|last }}

Edit the People section’s entry type settings, and add the Last Name field to its field layout.
Edit the People section’s main settings - just re-save them, so that all of your existing entries get updated.


Now when your People entries are saved, the last word in their Title will be copied over to a hidden “Last Name” field, and you can sort by that in your template:

{% set entries = craft.entries.section('people').order('lastName asc').limit(0) %}