Share array swap method.
The algorithm can be completely generic after all.