PropertyComparator.md•1.69 kB
## Package: dw.util
# Class PropertyComparator
## Inheritance Hierarchy
- Object
  - dw.util.PropertyComparator
## Description
This comparator can be used for the List sort() methods and for the SortSet and SortedMap classes. The comparator can be used to make a comparison based on a property of the contained objects. The Comparison is done based on the natural order of the values. It is guaranteed to work for Numbers, Strings, Dates, Money and Quantity values.
## Constructor Summary
PropertyComparator(property : String, otherProperties : String...) Constructs the comparator from the variable length argument list.
PropertyComparator(propertyName : String, sortOrder : boolean) Constructs the comparator.
PropertyComparator(propertyName : String, sortOrder : boolean, nullGreater : boolean) Constructs the comparator.
## Method Summary
### compare
**Signature:** `compare(arg1 : Object, arg2 : Object) : Number`
Compares its two arguments for order.
## Constructor Detail
## Method Detail
## Method Details
### compare
**Signature:** `compare(arg1 : Object, arg2 : Object) : Number`
**Description:** Compares its two arguments for order. Returns a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second. By default a null value is treated always greater than any other value. In the constructor of a PropertyComparator this default behavior can be changed.
**Parameters:**
- `arg1`: the first object to compare.
- `arg2`: the second object to compare.
**Returns:**
a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.
---