Euclidean Distance for grouping

  math, opencv, python

I want to calculate the euclidean distance between a point with all the other points in an image and possibly sort the top 5-6 with the smallest distance and count them as the nearby points. I know i must do it recursively for all the points in terms of the calculations but have anyone tried it before? I have the coordinates of all the points but not sure how to perform the calculation recursively and rank/sort them. Please I would appreciate any form of help. Thank you.

Source: Python Questions