I'd like to know how I can sort a DataObjectSet that I've filled with ArrayData. I know I can sort it using the sort() method but I've tried different ways and never got a result.
On my Page_Controller I have roughly this function:
function()
{
$provinces = DataObject::get('Province'
$doSet = new DataObjectSet();
foreach($provinces as $province)
{
$amount = $province->Tips()->Count();
$provinceTitle = $province->Title;
$provinceID = $province->ID;
$record = array('ProvId' => $provinceID, 'ProvTitle' => $provinceTitle, 'ProvTotal'=> $amount);
$Ad = new ArrayData($record);
$doSet->push($Ad)
}
return $doSet;
}
The reason it's on Page_Controller is that I want to call it on different types of pages...
I tried using
$provinces->groupBy(Title) as $province
too but that gave an error.
I would like to sort the data by ProvTitle, any hints on how to obtain this?
I was thinking of
$newSet = $doSet->sort(?????????)
But I'm not sure of how to write the argument to pass..