|
|
|
|
|
by romac
1328 days ago
|
|
I like how Rust does it with the `Ordering` type and associated combinators: https://doc.rust-lang.org/stable/std/cmp/enum.Ordering.html For two values `x` and `y` of the same type with fields `a` and `b`, this lets you compare on `a` first and then on `b` by writing ```
x.a.cmp(&y.a).then(x.b.cmp(&y.b))
``` |
|