def shell_sort(a) gap = a.size while(gap > 1) gap = gap / 2 (gap..a.size-1).each do |i| j = i while(j > 0) a[j], a[j-gap] = a[j-gap], a[j] if a[j] <= a[j-gap] j = j - gap end end end return a end