Step 1: i=5: Compare arr1[5]=20 > arr2[0]=2, swap arr1[5] ↔ arr2[0]
Array1: [1, 5, 9, 10, 15, 2]
Array2: [20, 3, 8, 13]
Why: Move smaller element from arr2 to arr1; larger to arr2
Step 2: Sort arr2 to restore order
Array1: [1, 5, 9, 10, 15, 2]
Array2: [3, 8, 13, 20]
Why: arr2[0] must always be the smallest in arr2 for correct comparisons
Step 3: i=4: arr1[4]=15 > arr2[0]=3, swap arr1[4] ↔ arr2[0]
Array1: [1, 5, 9, 10, 3, 2]
Array2: [15, 8, 13, 20]
Why: Continue placing smaller elements into arr1 from the end
Step 4: Sort arr2
Array1: [1, 5, 9, 10, 3, 2]
Array2: [8, 13, 15, 20]
Why: Maintain arr2 sorted with arr2[0] as smallest
Step 5: i=3: arr1[3]=10 > arr2[0]=8, swap arr1[3] ↔ arr2[0]
Array1: [1, 5, 9, 8, 3, 2]
Array2: [10, 13, 15, 20]
Why: Swap to push small element into arr1
Step 6: Sort arr2
Array1: [1, 5, 9, 8, 3, 2]
Array2: [10, 13, 15, 20]
Step 7: i=2: arr1[2]=9 <= arr2[0]=10, no swap
Array1: [1, 5, 9, 8, 3, 2]
Array2: [10, 13, 15, 20]
Why: No need to swap as arr1[2] is smaller
Step 8: i=1: 5 <=10, no swap; i=0: 1<=10, no swap
Array1: [1, 5, 9, 8, 3, 2]
Array2: [10, 13, 15, 20]
Why: All remaining arr1 elements are smaller than arr2[0]
Step 9: After loop, sort arr1 to restore order
Array1: [1, 2, 3, 5, 8, 9]
Array2: [10, 13, 15, 20]
Why: arr1 now contains all smallest elements, sorting finalizes it
Result: Array1: [1, 2, 3, 5, 8, 9]
Array2: [10, 13, 15, 20]