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

Function sort_rows

atomic-cli/src/commands/intent/list.rs:114–127  ·  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: IntentSort, reverse: bool)

Source from the content-addressed store, hash-verified

112/// sort), with id as the tiebreak. `reverse` flips the key,
113/// not the tiebreak.
114pub(crate) fn sort_rows(rows: &mut [Row], key: IntentSort, reverse: bool) {
115 rows.sort_by(|a, b| {
116 let ord = match key {
117 IntentSort::Id => a.human_key.cmp(&b.human_key),
118 IntentSort::HumanKey => compare_human_keys(&a.human_key, &b.human_key),
119 IntentSort::Title => a.title.cmp(&b.title),
120 IntentSort::Status => a.status.cmp(&b.status),
121 IntentSort::Kind => a.kind.cmp(&b.kind),
122 IntentSort::Attested => a.attested.cmp(&b.attested),
123 IntentSort::Verifies => a.verifies.cmp(&b.verifies),
124 };
125 if reverse { ord.reverse() } else { ord }.then_with(|| a.human_key.cmp(&b.human_key))
126 });
127}
128
129/// Compare the last key component numerically without imposing an integer limit.
130/// Invalid suffixes remain deterministic and group with their own prefix.

Callers 4

runMethod · 0.70
intent_listFunction · 0.50

Calls 3

compare_human_keysFunction · 0.85
cmpMethod · 0.45
reverseMethod · 0.45