冒泡:
public static void bubbleSort(Integer [] array){
for(int i = 0 ; i < array.length ; i++){
for(int j=i; j< array.length; j++){
if(array[i] >= array[j]){
int tmp = array[i];
array[i] = array[j];
array[j] = tmp;
}
}
}
}
插入排序:
public static void insertSort(Integer[] array){
for(int index = 1 ; index < array.length ; index++){
int currentValue = array[index];
int position = index;
for( ;position >0 && array[position-1]>currentValue;position--){
array[position] = array[position-1];
}
array[position] = currentValue;
}
}