dw.util
Class PropertyComparator

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.
Methods inherited from class
Object
assign, create, create, defineProperties, defineProperty, entries, freeze, fromEntries, getOwnPropertyDescriptor, getOwnPropertyNames, getOwnPropertySymbols, getPrototypeOf, hasOwnProperty, is, isExtensible, isFrozen, isPrototypeOf, isSealed, keys, preventExtensions, propertyIsEnumerable, seal, setPrototypeOf, toLocaleString, toString, valueOf, values
Constructor Detail
PropertyComparator
Constructs the comparator from the variable length argument list. The
parameters are property names that are to be used for the comparison.
When comparing two objects, the comparator first compares them by the
first property. If the two objects have equal values for the first
property, the comparator then compares them by the second property,
etc, until one object is determined to be less than the other or they are
equal. Each parameter must be either a simple name like "totalSum" or can
be a reference to a custom attribute like "custom.mytotal". Each
parameter may also be prefixed with an optional '+' or '-' character to
indicate that the objects should be sorted ascending or descending
respectively by that property. If not specified for a given property then
'+' (ascending sort) is assumed.
For example: new PropertyComparator("+prop1", "-prop2", "prop3")
constructs a Comparator which sorts by prop1 ascending, prop2 descending,
and finally prop3 ascending.
The comparator created with this constructor treats null values as
greater than any other value.
Parameters:
property
-
The property name to compare by first.
otherProperties
-
Additional property names to sort by if two objects have the same values for the first property.
PropertyComparator
public PropertyComparator(propertyName
:
String, sortOrder
:
boolean)
Constructs the comparator. The specified parameter is the name of the
property that is used for the comparison. The parameter must be either a
simple name like "totalSum" or can be a reference to a custom attribute
like "custom.mytotal".
The comparator created with this constructor is setup with ascending or
descending sort order depending on value of sortOrder and null values
being greater than any other value.
Parameters:
propertyName
-
the name of the property that is used for the comparison.
sortOrder
-
the sort order to use where true means ascending and false means descending.
PropertyComparator
public PropertyComparator(propertyName
:
String, sortOrder
:
boolean, nullGreater
:
boolean)
Constructs the comparator. The specified parameter is the name of the
property that is used for the comparison. The parameter must be either a
simple name like "totalSum" or can be a reference to a custom attribute
like "custom.mytotal".
Parameters:
propertyName
-
the name of the property that is used for the comparison.
sortOrder
-
the sort order to use where true means ascending and false means descending.
nullGreater
-
true means null is greater than any other value
Salesforce Commerce Cloud Courses
Salesforce B2C Commerce Developer - Certification Tests
Why risk failing the SFCC exam? Get 180 real questions, killer content, and everything you need to crush the Salesforce B2C Commerce Developer certification.
Becoming a Salesforce B2C Commerce Developer is your ticket to higher salaries, better job opportunities, and the credibility to stand out from the competition. But let's be honestβpassing the certification exam isn't easy. That's where we come in.
Becoming a Salesforce B2C Commerce Developer is your ticket to higher salaries, better job opportunities, and the credibility to stand out from the competition. But let's be honestβpassing the certification exam isn't easy. That's where we come in.
Salesforce Javascript Developer I - Certification Tests
Not just another prep courseβthis is your shortcut to passing. Master JavaScript for Salesforce and go from 'hoping to pass' to knowing you will. Ready to start?
This isn't just another prep courseβit's your shortcut to mastering the skills and confidence you need to pass. With multiple practice tests covering every section and a final exam simulation designed to mirror the real thing, you'll feel like you've already aced it before test day.
This isn't just another prep courseβit's your shortcut to mastering the skills and confidence you need to pass. With multiple practice tests covering every section and a final exam simulation designed to mirror the real thing, you'll feel like you've already aced it before test day.
Salesforce B2C Commerce Architect - Certification Tests
Think the Developer exam was hard? Welcome to the next level.
The Salesforce B2C Commerce Architect certification is a whole different gameβcomplex solutions, elevated difficulty, and skills that set you apart in the eCommerce industry. That's why we're including 11 downloadable PDF guides, packed with best practices and strategies to help you prepare for the exam and build confidence in every topic.
The Salesforce B2C Commerce Architect certification is a whole different gameβcomplex solutions, elevated difficulty, and skills that set you apart in the eCommerce industry. That's why we're including 11 downloadable PDF guides, packed with best practices and strategies to help you prepare for the exam and build confidence in every topic.
Method Detail
compare
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.