Fix unstable sort