euclidean bubble sort for vertices