I have any array of structs. Each struct in the array has the following attributes:
- user_id
- num_hot_dogs_eaten
- date_last_pigged_out
Here’s what I want to do:
-
Find the structs with matching user_id’s, and merge them into one struct record where num_hot_dogs_eaten is the sum of all matching records and date_last_pigged_out is the most-recent date the user pigged out.
-
Sort the array of structs by num_hot_dogs_eaten (first order of priority) and by date_last_pigged_out (second order of priority…most-recent first).
-
Return a new sorted array of structs.
Use this: