mirror of
				https://github.com/TeamPiped/sponsorblock-mirror.git
				synced 2024-08-14 23:57:05 +00:00 
			
		
		
		
	Sort all segments by start time.
This commit is contained in:
		
							parent
							
								
									525cded71e
								
							
						
					
					
						commit
						fe6f74d205
					
				
					 2 changed files with 11 additions and 0 deletions
				
			
		|  | @ -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…
	
	Add table
		Add a link
		
	
		Reference in a new issue