View source Improve this doc

orderBy
filter in module ng

Description

Orders a specified array by the expression predicate.

Usage

filter:orderBy(array, expression[, reverse]);

Parameters

ParamTypeDetails
arrayArray

The array to sort.

expressionfunction(*)stringArray.<(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.

Returns

Array

Sorted copy of the source array.

Example

Source







Demo