- #Insertion Sort Method
- def insertionSort(list)
- list.each_with_index do |data,i|
- j = i - 1
- while j >= 0
- break if list[j] <= data
- list[j + 1] = list[j]
- j = j - 1
- end
- list[j + 1] = data
- end
- end
- #该片段来自于http://www.codesnippet.cn/detail/240420132994.html
来源: http://www.codesnippet.cn/detail/240420132994.html