Bubble sorting, selection sorting and insertion sorting are the three most basic sorting algorithms. They seem very different at first look, but essentially they share the same principle underneath. The process could be split into two steps:
Partition the origin array into two sub-lists, one is ordered while the other is unordered.
Move one element from the unordered list to the ordered list, although in different ways:
bubble sorting: start from the end, compare the adjacent elements and switch them if the latter is larger. At last, we could move an element to the end of the ordered list.
selection sorting: traversal the unordered list, select the minimum number and put it to the end of the ordered list.
insertion sorting: pick the rightmost number in the unordered list and insert it in the right place of the ordered list.