/** * Returns a new DataObjectSet of the sorted array * @param string $fieldname the name of the field on the dataobject that you wish to sort the set by * @param string $direction the direction of the sort e.g. Ascending = ASC ( LIKE SQL ) */ public function sort($fieldname, $direction = "ASC") { if($this->items) { column_sort($this->items, $fieldname, $direction, false); } }
/** * Sorts the current DataObjectSet instance. * @param string $fieldname The name of the field on the DataObject that you wish to sort the set by. * @param string $direction Direction to sort by, either "ASC" or "DESC". */ public function sort($fieldname, $direction = "ASC") { if ($this->items) { if (preg_match('/(.+?)(\\s+?)(A|DE)SC$/', $fieldname, $matches)) { $fieldname = $matches[1]; $direction = $matches[3] . 'SC'; } column_sort($this->items, $fieldname, $direction, false); } }