mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
sort: fix whitespace and spelling
This commit is contained in:
parent
cc63565051
commit
2cdccb10bb
1 changed files with 8 additions and 8 deletions
|
@ -148,11 +148,11 @@ fn exec(files: Vec<String>, settings: &Settings) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Parse the beginning string into an f64, returning -inf instead of NaN on errors.
|
/// Parse the beginning string into an f64, returning -inf instead of NaN on errors.
|
||||||
fn permissive_f64_parse(a: &str) -> f64{
|
fn permissive_f64_parse(a: &str) -> f64 {
|
||||||
//Maybe should be split on non-digit, but then 10e100 won't parse properly.
|
// Maybe should be split on non-digit, but then 10e100 won't parse properly.
|
||||||
//On the flip side, this will give NEG_INFINITY for "1,234", which might be OK
|
// On the flip side, this will give NEG_INFINITY for "1,234", which might be OK
|
||||||
//because there's no way to handle both CSV and thousands separators without a new flag.
|
// because there's no way to handle both CSV and thousands separators without a new flag.
|
||||||
//GNU sort treats "1,234" as "1" in numeric, so maybe it's fine.
|
// GNU sort treats "1,234" as "1" in numeric, so maybe it's fine.
|
||||||
let sa: &str = a.split_whitespace().next().unwrap();
|
let sa: &str = a.split_whitespace().next().unwrap();
|
||||||
match sa.parse::<f64>() {
|
match sa.parse::<f64>() {
|
||||||
Ok(a) => a,
|
Ok(a) => a,
|
||||||
|
@ -160,14 +160,14 @@ fn permissive_f64_parse(a: &str) -> f64{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Compares two floating point numbers, with errors being assumned to be -inf.
|
/// Compares two floating point numbers, with errors being assumed to be -inf.
|
||||||
/// Stops coercing at the first whitespace char, so 1e2 will parse as 100 but
|
/// Stops coercing at the first whitespace char, so 1e2 will parse as 100 but
|
||||||
/// 1,000 will parse as -inf.
|
/// 1,000 will parse as -inf.
|
||||||
fn numeric_compare(a: &String, b: &String) -> Ordering {
|
fn numeric_compare(a: &String, b: &String) -> Ordering {
|
||||||
let fa = permissive_f64_parse(a);
|
let fa = permissive_f64_parse(a);
|
||||||
let fb = permissive_f64_parse(b);
|
let fb = permissive_f64_parse(b);
|
||||||
//f64::cmp isn't implemented because NaN messes with it
|
// f64::cmp isn't implemented because NaN messes with it
|
||||||
//but we sidestep that with permissive_f64_parse so just fake it
|
// but we sidestep that with permissive_f64_parse so just fake it
|
||||||
if fa > fb {
|
if fa > fb {
|
||||||
Ordering::Greater
|
Ordering::Greater
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue