Fixed two mistakes in sorting and switching from &x[0] to x.data() for returning a pointer to the underlying buffer of an std::vector.