Both failures came from the same root cause: `median` indexed into the list as given, so it only worked if the caller had already sorted it. It now sorts a copy of the input first (`xs = sorted(xs)`), which makes both the odd-length and even-length cases correct and leaves the caller's list untouched. `test_calc.py` was not modified.

All three tests pass.

DONE