class views_customfield_sorter in Views Custom Field 6
Hierarchy
- class \views_customfield_sorter
Expanded class hierarchy of views_customfield_sorter
File
- includes/
views_customfield_handler_field_phpcode.inc, line 213 - Contains the 'customfield' phpcode field handler.
View source
class views_customfield_sorter {
var $function;
var $factor;
var $field_alias;
function views_customfield_sorter($sortable, $sort_order, $field_alias) {
$this->factor = strtoupper($sort_order) == 'ASC' ? 1 : -1;
$functions = array(
VIEWS_CUSTOMFIELD_SORTABLE_NUMERIC => create_function('$a,$b', 'return $a-$b;'),
VIEWS_CUSTOMFIELD_SORTABLE_ALPHA => 'strcmp',
VIEWS_CUSTOMFIELD_SORTABLE_ALPHA_NOCASE => 'strcasecmp',
VIEWS_CUSTOMFIELD_SORTABLE_NAT => 'strnatcmp',
VIEWS_CUSTOMFIELD_SORTABLE_NAT_NOCASE => 'strnatcasecmp',
);
$this->function = $functions[$sortable];
$this->field_alias = $field_alias;
}
function sort($a, $b) {
return $this->factor * call_user_func($this->function, $a->{$this->field_alias}, $b->{$this->field_alias});
}
}