***
"I have the following **Python** function that **sorts a list of objects based on a dynamic key**. My current implementation uses a nested loop. Analyze this code and suggest an **optimization** that primarily reduces its **time complexity** (and secondarily, improves readability). Provide the refac