Correctly trigger sorting when needed