Sort entries for a single command by date

This commit is contained in:
Joscha 2021-12-05 18:28:00 +01:00
parent 4c83df76d4
commit 6d090b428f

View file

@ -43,11 +43,16 @@ impl<'a> CommandState<'a> {
Ok(self)
}
pub fn entries(self) -> Vec<Entry> {
self.dated
.into_values()
.chain(self.undated.into_iter())
.collect()
pub fn entries(mut self) -> Vec<Entry> {
let mut keys = self.dated.keys().copied().collect::<Vec<_>>();
keys.sort();
let mut entries = self.undated;
for key in keys {
entries.push(self.dated.remove(&key).unwrap());
}
entries
}
// Helper functions