actually fixed sort pairs bug