Major bug in sort functions resolved
The sort functions were simply swapping pointers within the functions
without changing places of the data in the vectors. This has now been
corrected.