Return sorted array given list of words