VDL Set Sorting
- a built-in comparator (see the VDL Reference for possible values).
- an expression that return a JavaScript array of ordered values.
- a function reference
- The built-in Boolean comparator can cope with Sets of type Boolean, Integer, or String, and will try to cast the value into a Boolean. For example:
- true values could be t, True, 1, true.
- false values could be f, False, 0, false.
- The built-in comparator days can be used to sort strings representing short or long names of days of the week in English, for example Mon, Tuesday.
- The built-in comparator months can be used to sort strings representing short or long names of months in English, for example Jan, December.
Example using a built-in comparator with a Set of strings
<vdl-set-sorter set="MonthsOfYear" comparator="months">
Example using a JavaScript array of ordered values to sort a Set of strings:
<vdl-set-sorter set="AlertLevels" comparator="=['Low', 'Medium', 'High', 'Critical']" direction="desc">
- less than 0 if a has a lower sorting value.
- 0 if a and b have equal sorting value.
- greater than 1 if a has a greater sorting value.
Example applying a custom comparator expression on a Set of strings
This sort the value A04 to the beginning of the data, and sort the rest of the values in alphabetical order:
<vdl-set-sorter set="AGENCY" comparator="=a === 'A04' ? -1 : b === 'A04' ? 1 : a.localeCompare(b)">
As a function reference:
<script> function sortAgencySet(a, b) { return a === 'A04' ? -1 : b === 'A04' ? 1 : a.localeCompare(b); } </script> <vdl-set-sorter set="AGENCY" comparator="=sortAgencySet">
© 2001-2020 Fair Isaac Corporation. All rights reserved. This documentation is the property of Fair Isaac Corporation (“FICO”). Receipt or possession of this documentation does not convey rights to disclose, reproduce, make derivative works, use, or allow others to use it except solely for internal evaluation purposes to determine whether to purchase a license to the software described in this documentation, or as otherwise set forth in a written software license agreement between you and FICO (or a FICO affiliate). Use of this documentation and the software described in it must conform strictly to the foregoing permitted uses, and no other use is permitted.