Jump to:

3460 Posts in 1064 Topics by 739 members

Data Model Questions

SilverStripe Forums » Data Model Questions » ArrayList Sort not working

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

Page: 1
Go to End
Author Topic: 516 Views
  • davidglassford
    Community Member
    1 Post

    ArrayList Sort not working Link to this 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


  • Willr
    Forum Moderator
    5508 Posts

    Re: ArrayList Sort not working Link to this post

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

Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.