MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / sort_rows

Function sort_rows

atomic-cli/src/commands/memory/list.rs:118–132  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

116/// sort), with id as the tiebreak. `reverse` flips the key,
117/// not the tiebreak.
118pub(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)]

Callers 2

runMethod · 0.70

Calls 2

cmpMethod · 0.45
reverseMethod · 0.45

Tested by 1