Python 使用选择排序对链接列表进行排序

Python 使用选择排序对链接列表进行排序,python,sorting,linked-list,Python,Sorting,Linked List,我正在使用选择排序算法对链表进行排序 我试着用列表来做,但做不到。 那么,有人能通过使用链表来帮助我实现这一点吗 这是到目前为止我的代码 from list_linked import List class Sorts: def selection_sort(a): current = a._front prv = None while current is not None: main_node = cur

我正在使用选择排序算法对链表进行排序 我试着用列表来做,但做不到。 那么,有人能通过使用链表来帮助我实现这一点吗

这是到目前为止我的代码

from list_linked import List
class Sorts:

    def selection_sort(a):


        current = a._front
        prv = None

        while current is not None:
            main_node = current
            prv = a._front
            current = current._next
            while current is not None:
                if main_node._value > current._value:
                    main_node = current
                else:
                    prv = prv._next
                current = current._next
            Sorts._swap(current, prv, main_node)

        return

    def _swap(self, first, prev, second):
        if first._next == second:
            second = self.swap_node(first)
        else:
            temp = first._next
            first._next = second._next
            second._next = temp
            prev._next = first
        return second, first

    def swap_node(self, node):
        second = node._next
        node._next = second._next
        second._next = node
        return second
我在查找时遇到的错误:

Method 'selection_sort - sorts_linked' should have self as first 
 parameter

请编辑您的问题,以包括您面临的具体问题。概述您期望代码做什么,以及它实际在做什么。如果您收到错误,请将其包含在question@wnnmaw:I adit it您正在使用类,消息
应将self作为第一个参数
意味着所有函数都应将self作为第一个参数
def selection\u sort(self,a)
,等等。上面的代码中没有以x=list\u开头的行链接,所以你没有向我们展示所有的代码