compare-numeric ()
Signatures
compare-numeric ( $first-item, $second-item [, $center] )
Compares two list items as numbers in ascending order. All non-numeric items are shifted right.
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 ()
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(10, 20);
// -10
// 2. As a reference
$list: 2 1 4 3;
@debug list.sort($list, list.compare-numeric());
// 1 2 3 4