Modified sample swap function to work as intended. Sorting function still needs to be implemented