Order `rows` by `key` (the local body's twin of the service's listing sort), with id as the tiebreak. `reverse` flips the key, not the tiebreak.
(rows: &mut [Row], key: MemorySort, reverse: bool)
| 116 | /// sort), with id as the tiebreak. `reverse` flips the key, |
| 117 | /// not the tiebreak. |
| 118 | pub(crate) fn sort_rows(rows: &mut [Row], key: MemorySort, reverse: bool) { |
| 119 | rows.sort_by(|a, b| { |
| 120 | let ord = match key { |
| 121 | // RFC 3339, so lexical == chronological. |
| 122 | MemorySort::Updated => b.updated.cmp(&a.updated), |
| 123 | MemorySort::Id => a.id.cmp(&b.id), |
| 124 | MemorySort::Kind => a.kind.cmp(&b.kind), |
| 125 | MemorySort::Status => a.status.cmp(&b.status), |
| 126 | MemorySort::About => a.about.cmp(&b.about), |
| 127 | MemorySort::Attested => a.attested.cmp(&b.attested), |
| 128 | MemorySort::Verifies => a.verifies.cmp(&b.verifies), |
| 129 | }; |
| 130 | if reverse { ord.reverse() } else { ord }.then_with(|| a.id.cmp(&b.id)) |
| 131 | }); |
| 132 | } |
| 133 | |
| 134 | /// The classification of one memory's attestation, for a table/JSON row. |
| 135 | #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] |