Sort in the order we expect them to be sorted in.

Same fix as 83ef80b86d83a1707040d22b1c276c9fdfd2f4d3.