We believe that writing is about content, about what you want to say – not about fancy formatting.
我們堅(jiān)信寫(xiě)作寫(xiě)的是內(nèi)容,所思所想,而不是花樣格式。
— Ulysses
插入排序基礎(chǔ)參見(jiàn):
2 排序基礎(chǔ) - 5插入排序法
查看上面插入排序基礎(chǔ)我們知道插入排序相比選擇排序可以提前結(jié)束第二層循環(huán),理論上應(yīng)該比選擇排序性能好,但實(shí)際用時(shí)卻很長(zhǎng),原因就是插入排序在遍歷的同時(shí)也在不停的交換:

1
要知道,交換(swap(a,b))這個(gè)操作是比簡(jiǎn)單的比較操作