在python3中,原有python2的cmp函数被删除。 cmp(a,b)=0 当a=b时 建议的替代方式为 (a>b)-(a<b), 当a>b时为1, a<b时为-1, a=b时为0. 在跨平台时需要注意。