reorder by edit distance