Levenshtein Distance Sort FIXED by I., S.

import Data.List
z=zipWith
main=interact$unlines.f.lines
f x@(h:_)=sortBy((.(h!)).compare.(h!))x
x!y=last$foldl(#)[0..][1:[sum[1|s/=t]|t<-y]|s<-x]
x#y=scanl1(%)$z(%)x$z(+)y$4:x
x%y=min(1+x)y

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return to the top page