Packageflare.util
Classpublic class Sort

Utility class for sorting and creating sorting functions. This class provides a static $() method for creating sorting comparison functions from sort criteria. Instances of this class can be used to encapsulate a set of sort criteria and retrieve a corresponding sorting function.

Sort criteria are generally expressed as an array of property names to sort on. These properties are accessed by sorting functions using the Property class. Sort criteria are expressed as an array of property names to sort on. These properties are accessed by sorting functions using the Property class. The default is to sort in ascending order. If the field name includes a "-" (negative sign) prefix, that variable will instead be sorted in descending order.



Public Properties
 PropertyDefined by
  comparator : Function
[read-only] Gets the sorting comparison function for this Sort instance.
Sort
  criteria : Array
The sorting criteria.
Sort
Public Methods
 MethodDefined by
  
Sort(crit:*)
Creates a new Sort instance to encapsulate sorting criteria.
Sort
  
$(... a):Function
[static] Creates a comparator function using the specification given by the input arguments.
Sort
  
defaultComparator(a:*, b:*):int
[static] Default comparator function that compares two values based on blind application of the less-than and greater-than operators.
Sort
  
sort(list:Array):void
Sorts the input array according to the sort criteria.
Sort
Public Constants
 ConstantDefined by
  ASC : Number
[static] Prefix indicating an ascending sort order.
Sort
  DSC : Number
[static] Prefix indicating a descending sort order.
Sort
Property detail
comparatorproperty
comparator:Function  [read-only]

Gets the sorting comparison function for this Sort instance.

Implementation
    public function get comparator():Function
criteriaproperty 
criteria:Array  [read-write]

The sorting criteria. Sort criteria are expressed as an array of property names to sort on. These properties are accessed by sorting functions using the Property class. The default is to sort in ascending order. If the field name includes a "-" (negative sign) prefix, that variable will instead be sorted in descending order.

Implementation
    public function get criteria():Array
    public function set criteria(value:Array):void
Constructor detail
Sort()constructor
public function Sort(crit:*)

Creates a new Sort instance to encapsulate sorting criteria.

Parameters
crit:* — the sorting criteria. Sort criteria are expressed as an array of property names to sort on. These properties are accessed by sorting functions using the Property class. The default is to sort in ascending order. If the field name includes a "-" (negative sign) prefix, that variable will instead be sorted in descending order.
Method detail
$()method
public static function $(... a):Function

Creates a comparator function using the specification given by the input arguments. The resulting sorting function can be used to sort objects based on their properties.

Parameters
... a — A multi-parameter list or a single array containing a set of data field names to sort on, in priority order. The default is to sort in ascending order. If the field name includes a "-" (negative sign) prefix, that variable will instead be sorted in descending order.

Returns
Function — a comparison function for use in sorting objects.
defaultComparator()method 
public static function defaultComparator(a:*, b:*):int

Default comparator function that compares two values based on blind application of the less-than and greater-than operators.

Parameters
a:* — the first value to compare
 
b:* — the second value to compare

Returns
int — -1 if a < b, 1 if a > b, 0 otherwise.
sort()method 
public function sort(list:Array):void

Sorts the input array according to the sort criteria.

Parameters
list:Array — an array to sort
Constant detail
ASCconstant
public static const ASC:Number

Prefix indicating an ascending sort order.

DSCconstant 
public static const DSC:Number

Prefix indicating a descending sort order.