Your question is Sorting Environmental Data. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
ERM Digital receives environmental monitoring records from multiple sites. Implement a function that returns the records in the required review order without modifying the original input list.
Sort records using these criteria, in order:
pollutant_priority list. Earlier pollutants have higher priority.value in descending order.timestamp in ascending chronological order. Timestamps use the format YYYY-MM-DDTHH:MM:SSZ and are in UTC.site in ascending lexicographical order.Implement sort_environmental_data(points, pollutant_priority).
points is a list of dictionaries with string fields site, pollutant, and timestamp, plus a numeric field value.pollutant_priority is a list of pollutant names. Every record's pollutant appears exactly once in this list.points.def sort_environmental_data(points, pollutant_priority):