table: Add default option to perform_sort (#379)

This commit is contained in:
Floyd Wang 2024-10-24 18:15:12 +08:00 committed by GitHub
parent b7a1292d07
commit db041fea88
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 4 additions and 7 deletions

View file

@ -439,12 +439,9 @@ impl TableDelegate for StockTableDelegate {
if let Some(col) = self.columns.get_mut(col_ix) {
match col.id.as_ref() {
"id" => self.stocks.sort_by(|a, b| {
if sort == ColSort::Ascending {
a.id.cmp(&b.id)
} else {
b.id.cmp(&a.id)
}
"id" => self.stocks.sort_by(|a, b| match sort {
ColSort::Descending => b.id.cmp(&a.id),
_ => a.id.cmp(&b.id),
}),
_ => {}
}

View file

@ -506,7 +506,7 @@ where
let sort = sort.unwrap();
let sort = match sort {
ColSort::Ascending => ColSort::Descending,
ColSort::Ascending => ColSort::Default,
ColSort::Descending => ColSort::Ascending,
ColSort::Default => ColSort::Descending,
};