Created
July 30, 2014 15:10
-
-
Save AndyDangerous/6d5bf1d6763acabdc7b0 to your computer and use it in GitHub Desktop.
Sort
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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