Correct sorting in the history window