Skip to content

Instantly share code, notes, and snippets.

@kkdai
Created February 5, 2014 12:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kkdai/8822250 to your computer and use it in GitHub Desktop.
Save kkdai/8822250 to your computer and use it in GitHub Desktop.
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