tags:

views:

96

answers:

1

How to sort string names in array on ascending order .

I tried sort method but it fails to sort on name basis .

def words = ["orange", "blue", "apple", "violet", "green"]

I need to achieve like this :

["apple", "blue", "green", "orange", "violet" ]

thanks in advance.

+2  A: 
["orange", "blue", "apple", "violet", "green"].sort()
codedevour
hi chrsk, you saved my time.Thanks a lot .
srinath
@srinath, if answer is correct, then accept it.
Superfilin