fix rank sorting