Help: 12 - Introduction to Sorting


#1

Hello!
I would like to know what is wrong with this code:

my_array = [3, 4, 8, 7, 1, 6, 5, 9, 2]

# Call the sort! method on my_array below.
# my_array should then equal [1, 2, 3, 4, 5, 6, 7, 8, 9].
print my_array.sort

In the console it returns

[1, 2, 3, 4, 5, 6, 7, 8, 9]

Please could someone explain?


#2

you just need to include an exclamation point after .sort because it is a ruby method,

print my_array.sort!


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.