public function order($fields = array())
{
$orderBy = array();
$defaultSort = "ASC";
if (is_array($fields)) {
foreach ($fields as $field => $sort) {
// Numeric index - field as array entry, not key/value pair
if (is_numeric($field)) {
$field = $sort;
$sort = $defaultSort;
}
$this->order[$field] = strtoupper($sort);
}
} else {
$this->order[$fields] = $defaultSort;
}
return $this;
}