aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.rs20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs
index ff00732..40f434c 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -143,7 +143,7 @@ pub struct LogResult {
}
/// A player.
-#[derive(Debug, Clone)]
+#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Player {
/// Account name of the player.
account_name: String,
@@ -157,6 +157,22 @@ pub struct Player {
guild_id: Option<String>,
}
+impl PartialOrd for Player {
+ fn partial_cmp(&self, other: &Player) -> Option<std::cmp::Ordering> {
+ Some(self.cmp(other))
+ }
+}
+
+impl Ord for Player {
+ fn cmp(&self, other: &Self) -> std::cmp::Ordering {
+ (self.subgroup, &self.account_name, &self.character_name).cmp(&(
+ other.subgroup,
+ &other.account_name,
+ &other.character_name,
+ ))
+ }
+}
+
/// Outcome of the fight.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum FightOutcome {
@@ -485,7 +501,7 @@ fn extract_info(entry: &DirEntry, log: &Log) -> LogResult {
guild_id: guild_ids.get(&p.addr()).cloned(),
})
.collect::<Vec<Player>>();
- players.sort_by_key(|p| p.subgroup);
+ players.sort();
LogResult {
log_file: entry.path().to_path_buf(),