Tweaks to sorting