@Test public void whenSortUnsortedArrayOfTenIntegersThenResultSortedArrayOfTenIntegers() { BubbleSort bubl = new BubbleSort(); int[] unsortedArray = {5,3,7,9,112,1,6,8,11,4}; int[] sortedArray = {1,3,4,5,6,7,8,9,11,112}; assertThat(bubl.sort(unsortedArray), is(sortedArray)); }
public int[] sort (int[] values) { for (int i = values.length-1; i >= 0; i--) { for (int j = 0; j < i; j++) { if (values[j] > values[j+1]) { int tempValue = values[j]; values[j] = values[j+1]; values[j+1] = tempValue; } } } return values; }
BubbleSort { public int[] sort (int[] values) { for (int i = values.length-1; i >= 0; i--) { for (int j = 0; j < i; j++) { if (values[j] > values[j+1]) { int tempValue = values[j]; values[j] = values[j+1]; values[j+1] = tempValue; } } } return values; } }
BubbleSort { public int[] sort (int[] values) { for (int i = values.length-1; i >= 0; i--) { for (int j = 0; j < i; j++) { if (values[j] > values[j+1]) { int tempValue = values[j]; values[j] = values[j+1]; values[j+1] = tempValue; } } } return values; }  }
BubbleSort { public int[] sort (int[] values) { for (int i = values.length-1; i >= 0; i--) { for (int j = 0; j < i; j++) { if (values[j] > values[j+1]) { int tempValue = values[j]; values[j] = values[j+1]; values[j+1] = tempValue; } } } return values; }  int[] sort(int[] values); }
BubbleSort { public int[] sort (int[] values) { for (int i = values.length-1; i >= 0; i--) { for (int j = 0; j < i; j++) { if (values[j] > values[j+1]) { int tempValue = values[j]; values[j] = values[j+1]; values[j+1] = tempValue; } } } return values; }  int[] sort(int[] values);  }