mirror of
https://github.com/lov3b/ecb-rates.git
synced 2025-07-07 12:00:30 +02:00
Simplify down to show-days
This commit is contained in:
16
src/cli/sort_by.rs
Normal file
16
src/cli/sort_by.rs
Normal file
@ -0,0 +1,16 @@
|
||||
use clap::ValueEnum;
|
||||
|
||||
#[derive(Debug, ValueEnum, Clone)]
|
||||
pub enum SortBy {
|
||||
Currency,
|
||||
Rate,
|
||||
}
|
||||
|
||||
impl SortBy {
|
||||
pub fn get_comparer(&self) -> fn(&(&str, f64), &(&str, f64)) -> std::cmp::Ordering {
|
||||
match self {
|
||||
Self::Currency => |a, b| a.0.cmp(&b.0),
|
||||
Self::Rate => |a, b| a.1.total_cmp(&b.1),
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user