Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/322.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 按最后两位数字对数字列表排序_Python_Python 3.x - Fatal编程技术网

Python 按最后两位数字对数字列表排序

Python 按最后两位数字对数字列表排序,python,python-3.x,Python,Python 3.x,如何对列表进行排序2=[311409313202303410401105407408] 到 [101 301 401 202 407 408 409 410 311 313]您可以使用余数运算符获取最后两位数字,然后将这些数字用作以下项的键: 输出 [101, 301, 401, 202, 303, 104, 204, 105, 305, 306, 407, 408, 409, 410, 311, 313] 当您希望使用实际值来解决关系时,键是最后两位数字和实际值的元组。将为a中的负整数获得意

如何对列表进行排序2=[311409313202303410401105407408] 到
[101 301 401 202 407 408 409 410 311 313]

您可以使用余数运算符获取最后两位数字,然后将这些数字用作以下项的键:

输出

[101, 301, 401, 202, 303, 104, 204, 105, 305, 306, 407, 408, 409, 410, 311, 313]

当您希望使用实际值来解决关系时,键是最后两位数字和实际值的元组。

将为
a
中的负整数获得意外结果。
[101, 301, 401, 202, 303, 104, 204, 105, 305, 306, 407, 408, 409, 410, 311, 313]