Ordered words

var words = [[]]
var file = %f'unixdict.txt'

file.open_r(\var fh, \var err) ->
    || die "Can't open file #{file}: $#{err}"

fh.each { |line|
    line.trim!
    if (line == line.sort) {
        words[line.length] := [] << line
    }
}

say words[-1].join(' ')

Output:

abbott accent accept access accost almost bellow billow biopsy chilly choosy choppy effort floppy glossy knotty

Last updated