Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Data Model Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

ArrayList Sort not working

Go to End

2 Posts   1439 Views


Community Member, 1 Post

30 October 2013 at 2:15am

Hey all,

I'm new to silverstripe and trying to combine two dataobjects into an ArrayList and then sort it by Date/Created but It doesn't do the sort. I've included the code below.

$displayContent = ArrayList::create();

$projectPages = ProjectPage::get()->sort('Created', 'DESC');
$blogPages = BlogEntry::get()->sort('Created');

foreach ($projectPages as $projectPage) {
foreach ($blogPages as $blogPage) {


return $displayContent;

Thanks for any help



Forum Moderator, 5521 Posts

30 October 2013 at 7:02pm

Lists are mostly immutable (i.e operations on lists give you back new lists) so when you do your sort you need to get your list

$sorted = $list->sort('Created');