mirror of
https://github.com/lov3b/ecb-rates.git
synced 2025-02-22 18:00:11 +01:00
Sort the plain table by currency keys
This commit is contained in:
parent
4b51a41659
commit
b7fceb47f3
@ -85,7 +85,8 @@ async fn main() -> ExitCode {
|
|||||||
FormatOption::Plain => parsed
|
FormatOption::Plain => parsed
|
||||||
.iter()
|
.iter()
|
||||||
.map(|x| {
|
.map(|x| {
|
||||||
let t: Table = x.clone().into();
|
let mut t: Table = x.clone().into();
|
||||||
|
t.sort();
|
||||||
format!("{}", t)
|
format!("{}", t)
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
|
@ -37,6 +37,10 @@ impl Table {
|
|||||||
fn add_row(&mut self, row_left: String, row_right: String) {
|
fn add_row(&mut self, row_left: String, row_right: String) {
|
||||||
self.rows.push((row_left, row_right));
|
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 {
|
impl Display for Table {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user