1.bubbleSort冒泡排序模板
public static void bubbleSort(int[] array) {
boolean flag = false;
int temp = 0;
for (int i = 0; i < array.length - 1; i++) {
for (int j = 0; j < array.length - 1 - i; j++) {
if (array[j] > array[j + 1]) {
temp = array[j];
array[j] = array[j + 1];
array[j + 1] = temp;
flag = true;
}
}
if (!flag) {
break;
} else {
flag = false;
}
}
}
2.selectSort简单选择排序模板
public static void selectSort(int[] array) {
if (array == null || array.length < 2) {
return;
}
for (int i = 0; i < array.length - 1; i&#