我正在做我的小「家庭作業」。我想用我定義的函數對列表進行排序。如何通過自定義函數對列表進行排序?
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) –