diff --git a/src/records.rs b/src/records.rs index 6e1fedf..a8e1f6b 100644 --- a/src/records.rs +++ b/src/records.rs @@ -98,21 +98,21 @@ fn print_best_times() { } fn print_best_cars() { let best_cars = BEST_CARS.lock().unwrap(); - let mut car_count: HashMap = HashMap::new(); + let mut car_count: HashMap = HashMap::new(); // Count occurrences and store RQ - for ((_, rq, _), best_car) in best_cars.iter() { + for (_key, best_car) in best_cars.iter() { let entry = car_count .entry(best_car.car_rid.clone()) - .or_insert((0, *rq, best_car.clone())); - entry.0 += 1; + .or_insert((best_car.clone(), 0)); + entry.1 += 1; } // Convert to vector and sort by RQ first, then frequency let mut car_count_vec: Vec<_> = car_count.iter().collect(); - car_count_vec.sort_by(|a, b| a.1.2.rq.cmp(&b.1.2.rq).then(a.0.cmp(b.0))); + car_count_vec.sort_by(|a, b| a.1.0.rq.cmp(&b.1.0.rq).then(a.1.1.cmp(&b.1.1))); - for (_car_rid, (count, _rq, car_record)) in car_count_vec { + for (_car_rid, (car_record, count)) in car_count_vec { println!( "{},{},{},{},{}", car_record.rq, car_record.brand, car_record.only_name, car_record.year, count