Fix serialized_size not using a const ptr.
Rewrite serialization_internal_sort.