added the edit distance sorting