Fix a sort bug