So I have been learning to work with arrays in Groovy. I am wondering how to sort an array of strings alphabetically. My code currently takes string input from the user and prints them out in order and reverse order:
System.in.withReader {
def country = []
print 'Enter your ten favorite countries:'
for (i in 0..9)
country << it.readLine()
print 'Your ten favorite countries in order/n'
println country //prints the array out in the order in which it was entered
print 'Your ten favorite countries in reverse'
country.reverseEach { println it } //reverses the order of the array
How would I go about printing them out alphabetically?