Skip to content

Instantly share code, notes, and snippets.

@AndyDangerous
Created July 30, 2014 15:10
Show Gist options
  • Save AndyDangerous/6d5bf1d6763acabdc7b0 to your computer and use it in GitHub Desktop.
Save AndyDangerous/6d5bf1d6763acabdc7b0 to your computer and use it in GitHub Desktop.
Sort
array_a=[1,4]
array_b=[2,3]
ary = [array_a,array_b]
a = ary[0]
b = ary[1]
sorted = []
until ary.empty? do
if a.empty?
sorted << b.shift
elsif b.empty?
sorted << a.shift
elsif a.first < b.first
sorted << a.shift
else
sorted << b.shift
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment