Algorithms can come in all shapes and sizes. For example, this is a sorting algorithm that uses the swapping technique as well:
See how useful swapping can be in programming?
Make sure to spell out temp.
temp