使用具有相同输入的相同排序命令会在不同的计算机上生成不同的结果.我该如何解决这个问题?
我正在使用Python3,但脚本与此版本不兼容,我遇到了一些错误.现在我的cmp参数有问题.这是代码
def my_cmp(x,y):
counter = lambda x, items: reduce(lambda a,b:a+b, [list(x).count(xx) for xx in items])
tmp = cmp(counter(x, [2,3,4,5]), counter(y, [2,3,4,5]))
return tmp if tmp!=0 else cmp(len(x),len(y))
for i, t in enumerate([tmp[0] for tmp in sorted(zip(tracks, self.mapping[idx][track_selection[-1]].iloc[0]), cmp=my_cmp, key=lambda x:x[1])]):
img[i,:len(t)] = t
Run Code Online (Sandbox Code Playgroud)
我真的很感激如何在Python3中处理这个错误.