Sorting .4


#1

How do you pass? This is what it says:
Inside your method, add a line that calls .sort! on the arr array. Since it is the last line of the method, the sorted array will be returned.
Now test your work! After your method, make a new array called numbers that contains a few numbers like the example above.
Call your alphabetize method with your numbers array as the parameter and puts the result to the console.

Do you put .sort! on the argument cause that is where you have the arrangement / arr.


#2

Could you provide a link to the actual exercise ??

Inside your method, add a line that calls .sort! on the arr array. Since it is the last line of the method, the sorted array will be returned.

def myMethod( an_array )
   an_array.sort!
 end
arr = [3,1,7,4]
puts "Original array arr"
puts arr
puts "arr array after myMethod call"
myMethod(arr)
puts arr

They want you learn the fact
that using the sort method with exclamation mark
will change the underlying array itself


#3

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