...

/

Solution: Sorting Children's Names

Solution: Sorting Children's Names

Go over the implementation of sorting children's names using an array.

We'll cover the following...

Solution

array = []
input = nil
puts "Enter child names in class: (0 to finish)" 
until input == "0"
    input = gets.chomp 
    if input != "0"
        array << input 
    end
end
puts "Children names in order:"
puts array.sort.join(", ")
Sorting children's names

Explanation

  • Line 1: We create ...