我正在做我的小“家庭作业”。我想用我定义的函数对列表进行排序。如何通过自定义函数对列表进行排序?
for exp。
list = [[1], [1,2,3,4,5,6,7], [1,2,3], [1,2], [1,2,3,4], [1,2,3,4,5,6,7,8]]
function1: (the length of every small list)/10
function2: (the length of every small list)/12
and the first 3 lists judged by function1, and the other by function2
我想要的结果是什么:
list = [[1],[1,2],[1,2,3],[1,2,3,4],[1,2,3,4,5,6,7,8],[1,2,3,4,5,6,7]]
我已经可以不用函数排序其长度列表,所以请让我知道,如果你有任何想法。 谢谢!
通过列表的长度排序/ 10是完全一样由列表... – RemcoGerlich
附注的长度排序:只要你不这样做整数除法(当你有一个小数除法结果时舍去),没有保留'/ 10'的意思,排序顺序也是一样的。 – TidB
[如何按照一定的标准对列表进行排序]可能的重复(http://stackoverflow.com/questions/33940432/how-to-sort-list-according-certain-criterion) –