I have a numpy array:
a = np.array(["dcba", "abc", "bca", "bcda", "tda", "a"])
Now I have a vectorized Levenshtein edit distance function which measures distance of given string with given array, for example, for string ab:
l_distv("ab", a)
returns:
array([3, 1, 3, 4, 3, 1])
I'd like to sort an array in a way so that any element with edit distance smaller than 2 moves to first positions, while the rest are moved behind them without changing their order. So result would be:
array(["abc", "a", "dcba", "bca", "bcda", "tda"])
I've done this, but it's pretty ugly, I assume there is a more efficient way.
l_distv("ab", a)returnedarray([3, 1, 3, 4, 3, 0])instead?