Sort pagelist by Name

Permalink
I currently have a page list displaying 10 people per page in display order. I need this to display people in alphabetical order a-z on the second (surname) name (Names of the people are page names). Somehow I need to sort the array before I execute this line:

$pages = $pl->getPage();


The sorting options in the concrete5 core include
$pl->sortByName();
$pl->sortByNameDescending();


I need a sortBySurname() function!

 
JohntheFish replied on at Permalink Best Answer Reply
JohntheFish
sortByName sorts by the full page name (EDITED, missed that when I first read).

For Firstname/Surname you will need attributes to hold them and then sort by the attribute.

(If you have a big list, it may be a lot slower)

Or you could have a look at UberList with MagicData.
magpie replied on at Permalink Reply
Currently have 120+ names which is likely to grow.

Is there no way of sorting the pagelist by the second word (surname) in the page name field?
Remo replied on at Permalink Reply
Remo
you can use the sort function to inject some custom SQL, but I'd strongly recommend to avoid that. You'll use full table scans for every query you run. As john wrote, use an attribute to keep things clear and easy to handle, especially if you'll have more data.
magpie replied on at Permalink Reply
Thanks guys, I've decided to just keep it simple and use the sortByName() function. Anything custom in the future Imma go the attribute route.
JohntheFish replied on at Permalink Reply
JohntheFish
For future reference, By "big and slow" I mean thousands, not hundreds.

The actual performance depends on your server.