Your question is Efficient Grouping by Property. 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.
The Supermicro Server Dashboard receives an array of record objects, such as server health or inventory records. Implement a function that groups the records by a specified property without changing their order within each group.
The groups must appear in the order their property values are first encountered. Each record is a Python dictionary, and the grouping property is guaranteed to exist and contain a hashable value. Do not mutate the input list or its records.
Implement group_by_property(records, property_name).
records, a list of dictionaries, and property_name, a string identifying a dictionary key.def group_by_property(records, property_name):