Swaps the elements at indices i and j in the array arr.