| Package | system.comparators |
| Class | public class AlphaComparator |
| Inheritance | AlphaComparator Object |
| Implements | Comparator |
Example :
import system.comparators.AlphaComparator ;
var comp1:AlphaComparator = new AlphaComparator() ;
var comp2:AlphaComparator = new AlphaComparator( true ) ; // ignore case
var s0:String = "HELLO" ;
var s1:String = "hello" ;
var s2:String = "welcome" ;
var s3:String = "world" ;
trace( comp1.compare(s1, s2) ) ; // -1
trace( comp1.compare(s2, s1) ) ; // 1
trace( comp1.compare(s1, s3) ) ; // -1
trace( comp1.compare(s1, s1) ) ; // 0
trace( comp1.compare(s1, s0) ) ; // -1
trace( comp2.compare(s1, s0) ) ; // 0
| Property | Defined By | ||
|---|---|---|---|
| ignoreCase : Boolean
Allow to take into account the case for comparison. | AlphaComparator | ||
| nullsAreHigh : Boolean
Defines that null should be compared as higher than a non-null object (default false). | AlphaComparator | ||
| Method | Defined By | ||
|---|---|---|---|
AlphaComparator(ignoreCase:Boolean = false)
Creates a new AlphaComparator instance. | AlphaComparator | ||
compare(o1:*, o2:*, options:* = null):int
Returns an integer value to compare two String objects with an alphabetic order. | AlphaComparator | ||
| ignoreCase | property |
public var ignoreCase:BooleanAllow to take into account the case for comparison.
| nullsAreHigh | property |
nullsAreHigh:BooleanDefines that null should be compared as higher than a non-null object (default false).
public function get nullsAreHigh():Boolean public function set nullsAreHigh(value:Boolean):void| AlphaComparator | () | Constructor |
public function AlphaComparator(ignoreCase:Boolean = false)Creates a new AlphaComparator instance.
ParametersignoreCase:Boolean (default = false) — a boolean to define if the comparator ignore case or not.
|
| compare | () | method |
public function compare(o1:*, o2:*, options:* = null):intReturns an integer value to compare two String objects with an alphabetic order.
Parameters
o1:* — the first String object to compare.
| |
o2:* — the second String object to compare.
| |
options:* (default = null) — A boolean who indicates if the Comparator ignore the case or not. If this parameter is null the internal ignoreCase property is used.
|
int —
|
ArgumentError — If the two objects isn't Strings.
|