Skip to main content

compare-value ()

Signatures

compare-value ( $first-pair, $second-pair )

Compares two key/value pairs’ values 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-value ()

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-value(b 8em, f 10mm);
// 7

// 2. As a reference
$map: (b: 8em, f: 10mm, d: a, a: 3, c: 1cm, e: 2mm);

@debug list.sort($map, map.compare-value());
// f 10mm, c 1cm, e 2mm, a 3, b 8em, d a