Ruby | Array sort_by!() function
Last Updated :
24 Jan, 2022
Array#sort_by!() : sort_by!() is a Array class method which returns the enumerator for the sorted array.
Syntax: Array.sort_by!()
Parameter: Array
Return: the enumerator for the sorted array.
Example #1 :
Ruby
a = ["abc", " nil ", "dog"]
c = ["cat", "efg", "geeks"]
b = ["cow", "coal", "dog"]
arr = [a, b, c]
puts "sort_by!() method form :
|
Output :
sort_by!() method form : #
Example #2 :
Ruby
a = ["abc", " nil ", "dog"]
c = ["cat", "efg", "geeks"]
b = ["cow", "coal", "dog"]
puts "sort_by!() method form :
puts "sort_by!() method form :
puts "sort_by!() method form :
|
Output :
sort_by!() method form : #
sort_by!() method form : #
sort_by!() method form : #
Note : These Enumerator output values can be different depending upon the system.
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...