pub fn group<'a, T, K, F>(data: &'a [T], key: F) -> HashMap<K, Vec<&'a T>>Expand description
Groups elements by a key function.
Returns a HashMap where each key maps to a Vec of elements with that key.
ยงExample
use d3rs::array::group;
let data = vec!["apple", "apricot", "banana", "blueberry", "cherry"];
let grouped = group(&data, |s| s.chars().next().unwrap());
assert_eq!(grouped[&'a'].len(), 2);
assert_eq!(grouped[&'b'].len(), 2);
assert_eq!(grouped[&'c'].len(), 1);