BubbleSort is the cannonical example of an inefficient SortingAlgorithm?.
It works by moving through the array comparing each element with the next element and swapping them if they're in the wrong order. The processes is repeated until all the elements are in order.
int [] array; boolean sorted = false; while(!sorted) {
sorted = true; for (int i;i < array.length-1;i++)
sorted = false; int tmp = array[i?; array[i? = array[i+1?; array[i+1? = tmp;
}
}
BubbleSort does have some good features:
One page links to BubbleSort: