Add swap and sort functions.