Created
October 21, 2012 01:16
-
-
Save MelanieS/3925381 to your computer and use it in GitHub Desktop.
A bad sorting algorithm
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
unsorted_array = [5, 2, 8, 0, 9, 3, 1] | |
sorted_array = [] | |
count = 0 | |
while sorted_array.count != unsorted_array.count | |
unsorted_array.each do |i| | |
if i == count | |
sorted_array << i | |
end | |
end | |
count += 1 | |
end | |
puts sorted_array.to_s |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment