do -- find words whose characters are in alphabetical order local function isSorted( word : string ) : boolean for c = 1, # word - 1 do if word[ c ] > word[ c + 1 ] then return false end end return true end local sortedWords, maxLength = {}, 0 for word in io.lines( "unixdict.txt" ) do if isSorted( word ) then local thisLength = # word if thisLength >= maxLength then if thisLength > maxLength then sortedWords, maxLength = {}, thisLength end sortedWords[ # sortedWords + 1 ] = word end end end for _, w in ipairs( sortedWords ) do print( w ) end end