Fixes a sort bug