human-sort icon indicating copy to clipboard operation
human-sort copied to clipboard

Fix Edge Cases

Open dragazo opened this issue 3 years ago • 3 comments

Closes #1 and #2. Also extends sort to accept any array of T: AsRef<str>, in particular so that you can easily sort Vec<String> without having to use .sort_by(|a, b| compare(a, b)).

Breaking change: compare_chars_iters now returns Ordering instead of Result<Ordering, ()>. Err was returned if every loop iteration found no difference, but if we handle the (Some(_), None) and (None, Some(_)) cases there's no issue determining the result inside the function.

This also fixes a bug where we were implicitly expecting base 10 digits, but were using char::is_numeric which is any number-like unicode character, including fraction characters, etc. It now uses char::is_digit.

dragazo avatar Jul 06 '22 21:07 dragazo

is there any reason why this has not been merged?

horacimacias avatar Jun 28 '23 13:06 horacimacias

@horacimacias not that I know of. tbh it was taking so long I just ended up making my own crate that includes these fixes (not a drop in replacement, but very similar): https://crates.io/crates/numeric-sort

dragazo avatar Jun 28 '23 16:06 dragazo

awesome, thanks!

horacimacias avatar Jun 28 '23 17:06 horacimacias