The bug was that `median` indexed a middle element without sorting, so it only worked when the input happened to be ordered. It now sorts a copy — input sequence untouched, and it still accepts any iterable (list, tuple, generator). `mean` needed no change.

`python3 -m unittest -q` → `Ran 3 tests ... OK`.

DONE