diff --git a/src/autocomplete_helper.rs b/src/autocomplete_helper.rs index d408fe6..88ff831 100644 --- a/src/autocomplete_helper.rs +++ b/src/autocomplete_helper.rs @@ -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