ruby - Simple array sort and capitalize -
new ruby , trying stuff. code below convert array string while sorting , display sorted results. i'm struggling use of capitalize method caps sorted words. the_data = ["dog", "cat", "fish", "zebra", "swan", "rabbit", "horse", "albatros", "frog", "mouse", "duck"] puts "\nthe array:\n" puts the_data puts "\n" puts "\nthe sorted array, capitalized:\n" to_display = the_data.sort.join(("\n").capitalize) puts to_display you can use array#map capitalize each word of array to_display = the_data.sort.map(&:capitalize).join("\n") # => "albatros\ncat\ndog\nduck\nfish\nfrog\nhorse\nmouse\nrabbit\nswan\nzebra" if want capitalize letters, can use upcase to_display = the_data.sort.map(&:upcase).join("\n") # => "albatros\ncat\ndog\nduck\nfish\nfrog\nhorse\nmouse\nrabbit\nswa...