Sort the primitives.