I have a class called Graph to represent a connected undirected graph, I want to implement quicksort to sort the edges based on weights on the edges.
class Graph:
    def __init__(self, n):
        self.vertices = range(n)
        self.edges = set([(random.random(), i, j) for i in xrange(n) for j in xrange(n)])
    def qsort(self):
        if len(self.edges) <= 1:
            return self.edges
        else:
            return qsort([x for x in self.edges[1:] if x < self.edges[0]]) + [self.edges[0]] + qsort([x for x in self.edges[1:] if x >= self.edges[0]])
graph = Graph(10)
graph.qsort()
When I try to run the above, I get NameError: global name 'qsort' is not defined.
Can someone tell me what I am doing wrong?
 
     
    