Skip to the page
Results for “sort_by”
4 results, best first
-
The language › Structs, enums and shapes
The built-in shapes
…// true } To sort by a key without defining cmp, use sort_by; a tuple key sorts by several fields: struct P { name: str, n: int } fn main() { let ps = [P { name: "b", n: 2 }, P { name: "a", n: 2 }, P…
-
Start here › A tour of Auk
6. Doing several things at once
…10), price_from("gearhaus", 20), ] let best = quotes.sort_by(q => q.1).first() print(best) // some(("bolt-co", 10.1)) } An async fn can run as a task; await on a list runs them all concurrently.…
-
Reference › Core library
Lists
…xs.reverse() xs.sort() a sorted copy; stable; needs Ord xs.sort_by(key) by a key; a tuple key sorts by several fields xs.unique() keeps the first of each xs.enum(): [(int, T)] pairs each item with…
-
Reference › Cheat sheet
Core library (always available)
…group_by(key): {K: [T]} unique zip enum join(sep) · sort sort_by(key): stable sorted copies; tuples and lists compare element by element: sort_by(p => (-p.n, p.name)) · maps: remove(k): V? keys…