Ruby:简单的插入排序

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

 #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