+ 2
Ruby - What does "sort" do?
Since a[1] is "a", what exactly does "sort" do? a = ["b", "a", "d", "c"] a.sort puts a[1]
1 Respuesta
+ 5
b = a.sort
assigns a sorted version of 'a' to the variable 'b' , 'a' isn't changed
a.sort! (👈 exclamation mark)
sorts 'a' and assigns the sorted list to 'a'