Levenshtein Distance Sort FIXED by leonid

l=list(open('../fd/0'))
def d(a):
 x=range(99)
 for k in a:
\x09p=x;x=x[0]+1,
\x09for b,q,r in zip(l[0],p[1:],p):p=1+min(p,q,r-(k==b));x+=p,
 return p
print''.join(sorted(l,key=d))

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

download

return top