Fix sort bug