mirror of
https://github.com/lov3b/ecb-rates.git
synced 2025-02-22 09:50:10 +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
|
||||
.iter()
|
||||
.map(|x| {
|
||||
let t: Table = x.clone().into();
|
||||
let mut t: Table = x.clone().into();
|
||||
t.sort();
|
||||
format!("{}", t)
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
|
@ -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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user