Skip to content

Instantly share code, notes, and snippets.

@nextacademy-private
Created August 31, 2014 09:06
Show Gist options
  • Save nextacademy-private/2f8e76c07adaa1890d58 to your computer and use it in GitHub Desktop.
Save nextacademy-private/2f8e76c07adaa1890d58 to your computer and use it in GitHub Desktop.
Dictionary Sort
def dictionary_sort(arr)
# Your code here to sort the array
end
# ...your code here to initialize the program and take user input
@AtsushiT
Copy link

arr = ["apple", "dog", "book", "milk", "library"]

def dictionary_sort(arr)
  # Your code here to sort the array
  arr.sort!
end

# ...your code here to initialize the program and take user input

arr.each do |word|
  puts "Type a word: (if you want to finish, press just Enter Key)"
  answer = gets.chomp
  arr.push(answer)
  if answer.empty?
    break puts "Well done!"
  elsif 
    puts "OK, I got it"
  end
end

puts arr.sort!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment