mirror of
https://github.com/TeamPiped/sponsorblock-mirror.git
synced 2024-12-12 21:30:36 +05:30
Sort all segments by start time.
This commit is contained in:
parent
525cded71e
commit
fe6f74d205
@ -109,6 +109,10 @@ pub async fn skip_segments(
|
||||
}
|
||||
}
|
||||
|
||||
for sponsor in sponsors.values_mut() {
|
||||
sponsor.segments.sort_by(|a, b| a.partial_cmp(b).unwrap());
|
||||
}
|
||||
|
||||
if !sponsors.is_empty() {
|
||||
let sponsors: Vec<&Sponsor> = sponsors.values().collect();
|
||||
return content::RawJson(serde_json::to_string(&sponsors).unwrap());
|
||||
|
@ -1,3 +1,4 @@
|
||||
use std::cmp::Ordering;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||
@ -30,3 +31,9 @@ impl PartialEq for Segment {
|
||||
self.uuid == other.uuid
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialOrd for Segment {
|
||||
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
|
||||
self.segment[0].partial_cmp(&other.segment[0])
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user