Created
February 5, 2014 12:00
-
-
Save kkdai/8822250 to your computer and use it in GitHub Desktop.
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
def quickSort_bigendian(input_arry) | |
index_i = 0 | |
puts "Before sort" | |
puts input_arry.inspect | |
while (index_i < input_arry.size) | |
index_j = input_arry.size | |
index_j -= 1 | |
while (index_j > index_i) | |
if ( input_arry[index_j] < input_arry[index_j-1] ) | |
temp = input_arry[index_j-1] | |
input_arry[index_j-1] = input_arry[index_j] | |
input_arry[index_j] = temp | |
end | |
index_j -= 1 | |
end | |
index_i += 1 | |
end | |
puts "After sort" | |
puts input_arry.inspect | |
end | |
arry = [53,6,34,167,90,34,51,111,53,78] | |
puts arry.inspect | |
quickSort_bigendian(arry) #it is call by reference, object ID is the same | |
puts arry.inspect |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment