'Sort numpy matrix based on a comparator function

I have a vector v and a matrix M. I want to sort M row-wise by comparing each row to v with Euclidean distance (np.linalg.norm) and sort from least distance to greatest distance. I've looked into np.argsort but am not sure how to apply it to this instance or if it even works here. Any help would be greatly appreciated!

Example input:

k = 5
n = 3
M = np.random.randn(k, n)
v = [1, 2, 3, 4, 5]


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source