sort cryps
This commit is contained in:
@@ -189,8 +189,9 @@ pub fn account_cryps(tx: &mut Transaction, account: &Account) -> Result<Vec<Cryp
|
||||
return Err(err_msg("could not deserialize a cryp"));
|
||||
}
|
||||
|
||||
// now unwrap is safe
|
||||
return Ok(cryps.unwrap());
|
||||
let mut cryps = cryps.unwrap();
|
||||
cryps.sort_by_key(|c| c.id);
|
||||
return Ok(cryps);
|
||||
}
|
||||
|
||||
pub fn account_game_history(tx: &mut Transaction, account: &Account) -> Result<Vec<Game>, Error> {
|
||||
|
||||
@@ -160,6 +160,7 @@ impl Game {
|
||||
let index = team.cryps.iter().position(|t| t.id == cryp.id).unwrap();
|
||||
team.cryps.remove(index);
|
||||
team.cryps.push(cryp.clone());
|
||||
team.cryps.sort_unstable_by_key(|c| c.id);
|
||||
},
|
||||
None => panic!("cryp not in game"),
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user