compare-key ()
Signatures
compare-key ( $first-pair, $second-pair )
Compares two key/value pairs’ keys by converting them to strings, then comparing the value’s sequences of UTF-16 code units values in ascending order. All null items are shifted right.
Details
Parameters
$first-pair
- The first key/value pair for the comparison.
- Type
*
$second-pair
- The second key/value pair for the comparison.
- Type
*
Return Value
Number
- A positive number when the first given value is greater than the second given value, or a negative number when the second given value is greater than the first given value; otherwise, zero.
compare-key ()
Returns a function reference to this string comparison method to be used by the sort function.
Details
Return Value
Function
- A reference to this string comparison method.
Example
@use '@sass-fairy/list';
@use '@sass-fairy/map';
// 1. As a call
@debug map.compare-key(b 8em, f 10mm);
// -4
// 2. As a reference
$map: (b: 8em, f: 10mm, d: a, a: 3, c: 1cm, e: 2mm);
@debug list.sort($map, map.compare-key());
// a 3, b 8em, c 1cm, d a, e 2mm, f 10mm