N = gets.to_i s = [] N.times do |str| s.push(gets.chomp) end s.sort.each do |str| puts str end