Collection/orderBy
From PunchCMS
Collection->orderBy(property, [order])
Overview
Order a collection of objects by property name ascending or descending.
Arguments
property [string]
The name of the object property. Could be "created", "sort" or "name".
order [string, optional]
Set the order direction. Can be "asc" to order ascending or "desc" to order descending. Default is "asc".
Returns
Nothing
Example
$objCms = PCMS_Client::getInstance(); // Order Elements by "modified" date descending. $objElements = $objCms->getElementsByTemplate("Page"); $objElements->orderBy("modified", "desc"); foreach ($objElements as $objElement) { // Loop through the elements. }