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
|
/// https://www.dotnetperls.com/sort-rust
|
||||||
fn compare_len_reverse_alpha(a: &String, b: &String) -> Ordering {
|
fn compare_len_reverse_alpha(a: &String, b: &String) -> Ordering {
|
||||||
// Sort by length from short to long first.
|
match a.len().cmp(&b.len()) {
|
||||||
let length_test = a.len().cmp(&b.len());
|
Ordering::Equal => b.cmp(a),
|
||||||
if length_test == Ordering::Equal {
|
order => order,
|
||||||
// If same length, sort in reverse alphabetical order.
|
|
||||||
return b.cmp(a);
|
|
||||||
}
|
}
|
||||||
length_test
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Generates hashmap (well really a vector of tuple of strings that are then
|
/// Generates hashmap (well really a vector of tuple of strings that are then
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user