add separate sort order field to levels, so they can be reordered without changing the id and invalidating solutions
This commit is contained in:
parent
90bc93fa02
commit
e43a422708
6 changed files with 27 additions and 11 deletions
|
@ -3,6 +3,7 @@ use serde::Deserialize;
|
|||
#[derive(Debug, Clone, Deserialize)]
|
||||
pub struct Level {
|
||||
id: String,
|
||||
sort_order: i32,
|
||||
name: String,
|
||||
description: String,
|
||||
init_board: Option<String>,
|
||||
|
@ -15,6 +16,10 @@ impl Level {
|
|||
&self.id
|
||||
}
|
||||
|
||||
pub fn sort_order(&self) -> i32 {
|
||||
self.sort_order
|
||||
}
|
||||
|
||||
pub fn name(&self) -> &str {
|
||||
&self.name
|
||||
}
|
||||
|
|
|
@ -236,7 +236,7 @@ fn get_levels() -> Vec<Level> {
|
|||
levels.push(level);
|
||||
}
|
||||
}
|
||||
levels.sort_by(|a, b| a.id().cmp(b.id()));
|
||||
levels.sort_by(|a, b| a.sort_order().cmp(&b.sort_order()));
|
||||
levels
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue