1 Step by step: {6, 3, 0, 5, 1} {3, 6, 0, 5, 1} {3, 0, 6, 5, 1} {3, 0, 5, 6, 1} {3, 0, 5, 1, 6} {0, 3, 5, 1, 6} {0, 3, 5, 1, 6} {0, 3, 5, 1, 6} {0, 3, 1, 5, 6} {0, 3, 1, 5, 6} {0, 1, 3, 5, 6} {0, 1, 3, 5, 6} public static void bubbleSort(int[] ar) { int tmp; for(int p1=0; p1 < ar.length-1; p1++){ for (int p2=0; p2 < ar.length-1-p1; p2++){ if (ar[p2] > ar[p2+1]){ tmp = array[p2]; array[p2] = array[p2+1]; array[p2+1] = tmp; } } } }