Fix for handling done-state in sorting