// naive implementation // sorts an array of ints in increasing order public static void bubbleSort(int[] a) { // N passes for an array of length N for (int pass = 1; pass <= a.length; pass++) { // for each pass, compare pairs of values for (int curr = 0; curr < a.length -1; curr++) { // swap values in pair if the are out of order if (a[curr] > a[curr + 1]) { int temp = a[curr]; a[curr] = a[curr+1]; a[curr+1] = temp; } } } }