Wolfram Language (Mathematica), 67 bytes
Full programAssumes the Notebook environment. Otherwise an extra Print
needs to be added around the last part of the code (as is done in the TIO link).
f=(a=Characters@ToLowerCase@#;a==AlphabeticSort@a)&/@#&;l~Pick~f[l]
This code assumes a lexicon has been defined previously and saved in the variable l
. It maps the function f
over each word in the lexicon and keeps only words for which f
returns True
. f
in turn takes in a word, lowercases it, and then puts the letters in the string individually into a list. It returns true if the list does not change when AlphabeticSort
is run on it. AlphabeticSort
takes in a list of strings and sorts them in alphabetic order into a new list. The ToLowerCase
function call is needed because AlphabeticSort
sorts lowercase letters before their uppercase version, and so f
fails to find "Oort" because it gets sorted into {"o","O","r","t"}, which desn'tdoesn't match the original character order.