What this Python language-knowledge question tests
This is a medium-difficulty question that probes your familiarity with Python's built-in sorting behaviour and how the language handles edge cases in common operations. It rewards careful reading of code execution rather than algorithmic insight.
To answer correctly, you need to understand how Python's sort() method and sorted() function behave on different data types, what the default ordering rules are, and how Python handles comparisons in contexts you may not have explicitly considered. The question tests whether you can trace through code mentally without running it—a valuable skill in interview settings where you must reason about behaviour quickly and accurately.
- Mutability and in-place vs. functional sorting
- Default comparison rules for built-in types
- Stability of Python's sort algorithm