If you call sort multiple times only the last call should have an effect. If this last call is a null I cleanup the previous sort settings.

Of course I could refactor it to use the ternary operator, so it is a one liner.