Skip to content

Instantly share code, notes, and snippets.

@rorhug
Last active December 24, 2015 10:38
Show Gist options
  • Save rorhug/6785182 to your computer and use it in GitHub Desktop.
Save rorhug/6785182 to your computer and use it in GitHub Desktop.
def lrgst(a)
largest = 0
a.each {|i| largest = i if i > largest }
largest
end
def radix_lsd(uns)
sorted = (0..Math.log10(lrgst(uns)).floor).inject(uns) do |memo, index|
groups = Array.new(10).map{|x| [] }
memo.each { |u| groups[(u / 10**index) % 10] << u }
groups.flatten
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment