Your question is Sorting Algorithm Implementation. 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.
A Cirrus Logic audio validation pipeline produces measurements from codec tests. Each measurement is a dictionary with a latency_us integer and a test_id string. Implement a stable sorting algorithm that returns the measurements in ascending order of latency_us without using Python's built-in sorting functions.
If two measurements have the same latency, preserve their original relative order. The input list must not be modified.
Implement sort_measurements(measurements), where measurements is a list of dictionaries containing:
latency_us: an integer latency valuetest_id: a string identifierReturn a new list containing the same dictionaries, ordered by increasing latency_us. A merge sort is expected because it provides predictable O(n log n) time and demonstrates how to preserve stability.
def sort_measurements(measurements):