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.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Data Model Questions /

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

Reverse order of a DataObjectSet()

Go to End

3 Posts   3363 Views


Community Member, 21 Posts

19 February 2009 at 5:40am

I'd like to reverse the order of DataObjectSet() as I'm using it for search results and it returns the pages ascending order of creation rather than descending.

mentions a sort function but I'm not sure if its what im looking for

and great cms and thanks for all the help in the past btw :)


Forum Moderator, 5523 Posts

19 February 2009 at 12:51pm

You can do this inside your DataObject::get() call. The sort parameter is the 3rd one - eg DataObject::get('Page','','Created DESC');

You can also use that sort you mentioned. $myDataObjectSet->sort('Created', 'DESC');


Community Member, 21 Posts

21 February 2009 at 6:20am

Thats great, thought it would be something simple :)

thanks will!