Skip to main content

compare-string-desc ()

Signatures

compare-string-desc ( $first-item, $second-item )

Compares two list items by converting them to strings, then comparing the value’s sequences of UTF-16 code units values in descending order. All null items are shifted left.

Details

Parameters

$first-item
The first item for the comparison.
Type
*
$second-item
The second item 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-string-desc ()

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';

// 1. As a call
@debug list.compare-string-desc('x', 'm');
// -11

// 2. As a reference
$list: 'x' 'm' 'b' 't';

@debug list.sort($list, list.compare-string-desc());
// 'x' 't' 'm' 'b'