Sort the plain table by currency keys

This commit is contained in:
Love 2025-01-07 16:06:22 +01:00
parent 4b51a41659
commit b7fceb47f3
2 changed files with 6 additions and 1 deletions

View File

@ -85,7 +85,8 @@ async fn main() -> ExitCode {
FormatOption::Plain => parsed
.iter()
.map(|x| {
let t: Table = x.clone().into();
let mut t: Table = x.clone().into();
t.sort();
format!("{}", t)
})
.collect::<Vec<_>>()

View File

@ -37,6 +37,10 @@ impl Table {
fn add_row(&mut self, row_left: String, row_right: String) {
self.rows.push((row_left, row_right));
}
pub fn sort(&mut self) {
self.rows.sort_by(|a, b| a.1.cmp(&b.1))
}
}
impl Display for Table {