Bubble Sort
Array
   Step-by-Step Animation   Animation Speed 
Elaboration:
?
Bubble Sort: This algorithm sorts (horribly) in O(n2) where n is the size of the input array/vector.
The algorithm is fully explained, with more references, here.
The following code is a snippet of what is found at the link, but it's the most relevent piece:
Given:
Array v of n values to be sorted
Method:
for(i = 0; i < n - 1; i++) {
  for(j = 0; j < n - i - 1; j++){
    if(v[j] > v[j + 1]){
      tmp = v[j];
      v[j] = v[j + 1];
      v[j + 1] = tmp;
    }
  }
}
          
冒泡排序定义: 冒泡排序是一种比较简单的排序,它是从前往后依次比较相邻的两个数,将比较小的数放在前面,比较大的数放在后面。按顺序遍历比较后得到的最大数放置末尾,接着继续从头开始遍历直到比较完成。
Method:
for(i = 0; i < n - 1; i++) {
  for(j = 0; j < n - i - 1; j++){
    if(v[j] > v[j + 1]){
      tmp = v[j];
      v[j] = v[j + 1];
      v[j + 1] = tmp;
    }
  }
}