我正在尝试使用Merge Sort对链接列表进行排序。当我运行Programm时出现错误
x = list_linked.merge_sort(l)
AttributeError: 'module' object has no attribute 'merge_sort'
这是我在文件中的功能(list_l):
def merge_sort(a):
a._front = merge_sort_aux(a._front)
return
def merge_sort_aux(a)
if a is not None and a._next:
left, right = merge_sort_aux(a)
left = merge_sort_aux(left)
right = merge_sort_aux(right)
a = merge_sort_aux(left, right)
return a
这里是主要的:
from list_l import List
import list_linked
a = [3, 4, 5, 3, 6, 3, 5, 2, 5]
l = List()
for i in a:
l.append(i)
x = list_l.merge_sort(l)
print(x)
同样在我的函数中我得到错误:
Method 'merge_sort - sorts_linked' should have self as first
parameter
Method 'merge_sort_aux - sorts_linked' should have self as first
parameter
感谢您的帮助。