model/project: simplify file selection sorting logic
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I0acf8e690157f1926a2658165592199d6a6a6964
This commit is contained in:
parent
0fecd1486b
commit
d4938c4ae8
1 changed files with 4 additions and 13 deletions
|
|
@ -261,20 +261,11 @@ impl Project {
|
|||
)));
|
||||
}
|
||||
|
||||
// Sort by release type (release > beta > alpha) and date
|
||||
let mut sorted_files = compatible_files.clone();
|
||||
// Sort by release type (Release < Beta < Alpha) and date (newest first)
|
||||
let mut sorted_files = compatible_files.to_vec();
|
||||
sorted_files.sort_by(|a, b| {
|
||||
use super::enums::ReleaseType;
|
||||
let type_order = |rt: &ReleaseType| {
|
||||
match rt {
|
||||
ReleaseType::Release => 0,
|
||||
ReleaseType::Beta => 1,
|
||||
ReleaseType::Alpha => 2,
|
||||
}
|
||||
};
|
||||
|
||||
type_order(&a.release_type)
|
||||
.cmp(&type_order(&b.release_type))
|
||||
a.release_type
|
||||
.cmp(&b.release_type)
|
||||
.then_with(|| b.date_published.cmp(&a.date_published))
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue