2007-12-13から1日間の記事一覧

Rubyでクイックソート

仕事中に見つけて思わずのめりこんでしまいました。 http://rubygof.googlecode.com/svn/trunk/strategy.rb class QuickSort def sort arr return [] if arr.length == 0 x, *xs = *arr smaller, bigger = xs.partition{ |other| other < x } sort(smaller) …