For a class project, I need to use python 2.1, and I'll probably have to use DSU for sorting, which I'm not familiar with. So I'd like some help if possible.
I have a list for storing vertexes and their coordinates. for example
vertex = [(2, 2), (3, 3), (1, 1)]
and so on.
I also have another list which will store the index positions of the vertex, sorted according to their first coordinate. So it will start like this
order = [0, 1, 2]
And my objective is for it to be like this, considering the example
order = [2, 0, 1]
without changing the order in the list "vertex".
Any ideas? Thanks in advance
I don't know if it works in Python2.1, but either of the following does what you ask in Python2.7:
or
This probably works in Python2.1 (I don't have Python 2.1 installed to test it).