Documentation

SortFieldsTrait

A simple sorter for object.

The 'mode' parameter for compare() and Arrays::createSort can be any field name or virtual field from an ArrayableFields object.

The 'default' mode is provided by a getSortKey().

All comparisons are done with the spaceship operator.

Tags
see
Arrays::sort
mixin

Table of Contents

Methods

compare()  : int
Compare this object to another.
getSortKey()  : string
A default sort key for this object.

Methods

compare()

Compare this object to another.

public compare(mixed $other[, string $mode = 'default' ]) : int
Parameters
$other : mixed
$mode : string = 'default'
Return values
int

getSortKey()

A default sort key for this object.

public abstract getSortKey() : string

When given the 'default' mode the sorter will use this. HOWEVER the default mode can be changed for each 'Sortable' class. See below.

Use caution if you plan to change this within child classes. Don't go changing this often if you want consistent sorts.

The comparison is performed by the spaceship operator. Meaning numeric string will sort naturally as numbers, not as alphabetically.

Return values
string
On this page

Search results