orderBy
(filter in module ng
)
Orders a specified array
by the expression
predicate.
Note: this function is used to augment the Array
type in Angular expressions. See
angular.module.ng.$filter
for more informaton about Angular arrays.
orderBy(array, expression[, reverse]);
array – {Array} –
The array to sort.
expression – {function(*)|string|Array.<(function(*)|string)>} –
A predicate to be used by the comparator to determine the order of elements.
Can be one of:
function
: Getter function. The result of this function will be sorted using the
<
, =
, >
operator.string
: An Angular expression which evaluates to an object to order by, such as 'name'
to sort by a property called 'name'. Optionally prefixed with +
or -
to control
ascending or descending sort order (for example, +name or -name).Array
: An array of function or string predicates. The first predicate in the array
is used for sorting, but when two items are equivalent, the next predicate is used.reverse(optional) – {boolean=} –
Reverse the order the array.
{Array}
– Sorted copy of the source array.