Reimplementation of Sort_ints_ which I hope will avoid the bgclang bug.