cleanup compare_len_reverse_alpha
This commit is contained in:
parent
9e07a3c981
commit
ea683628a0
@ -3,13 +3,10 @@ use std::collections::HashSet;
|
||||
|
||||
/// https://www.dotnetperls.com/sort-rust
|
||||
fn compare_len_reverse_alpha(a: &String, b: &String) -> Ordering {
|
||||
// Sort by length from short to long first.
|
||||
let length_test = a.len().cmp(&b.len());
|
||||
if length_test == Ordering::Equal {
|
||||
// If same length, sort in reverse alphabetical order.
|
||||
return b.cmp(a);
|
||||
match a.len().cmp(&b.len()) {
|
||||
Ordering::Equal => b.cmp(a),
|
||||
order => order,
|
||||
}
|
||||
length_test
|
||||
}
|
||||
|
||||
/// Generates hashmap (well really a vector of tuple of strings that are then
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user