1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

sort: simplify handling of negative zeros

We can simply parse the sign of negative zero as positive, instead of
handling the comparison of zeros differently.
This commit is contained in:
Michael Debertol 2021-06-01 18:09:39 +02:00
parent 06b3092f5f
commit 67b83647ac

View file

@ -107,7 +107,7 @@ impl NumInfo {
} else {
(
NumInfo {
sign: if had_digit { sign } else { Sign::Positive },
sign: Sign::Positive,
exponent: 0,
},
if had_digit {
@ -147,7 +147,7 @@ impl NumInfo {
} else {
(
NumInfo {
sign: if had_digit { sign } else { Sign::Positive },
sign: Sign::Positive,
exponent: 0,
},
if had_digit {
@ -187,11 +187,7 @@ impl NumInfo {
pub fn numeric_str_cmp((a, a_info): (&str, &NumInfo), (b, b_info): (&str, &NumInfo)) -> Ordering {
// check for a difference in the sign
if a_info.sign != b_info.sign {
return if a.is_empty() && b.is_empty() {
Ordering::Equal
} else {
a_info.sign.cmp(&b_info.sign)
};
return a_info.sign.cmp(&b_info.sign);
}
// check for a difference in the exponent