Skip to main content

compare-numeric-desc ()

Signatures

compare-numeric-desc ( $first-item, $second-item [, $center] )

Compares two list items as numbers in descending order. All non-numeric items are shifted left.

Details

Parameters

$first-item
The first item for the comparison.
Type
*
$second-item
The second item for the comparison.
Type
*
$center
The value indicating the center (zero) position between positive and negative values.
Type
Number
Default
0

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-numeric-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-numeric-desc(10, 20);
// 10

// 2. As a reference
$list: 2 1 4 3;

@debug list.sort($list, list.compare-numeric-desc());
// 4 3 2 1