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

ArrayList Sort not working


2 Posts   542 Views


30 October 2013 at 2:15am Community Member, 1 Post

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



30 October 2013 at 7:02pm Forum Moderator, 5511 Posts

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');