2015-10-06, 17:10
really apologize if this question doesn't belong in this section, but may be someone can help me out here since it may be related more to kodi than python.
I've searched and searched but can't find an answer for this sorting dilemma shown below which works in python 2.7.6 IDLE shell.
my_list = [('462000', 'http://xxxxx.net/i/videos/vod/xxxxx/index_0_av.m3u8?null='), ('862000', 'http://xxxxx.net/i/videos/vod/xxxxx/index_1_av.m3u8?null='), ('1378000', 'http://xxxxx.net/i/videos/vod/xxxxx/index_2_av.m3u8?null='), ('2074000', 'http://xxxxx.net/i/videos/vod/xxxxx/index_3_av.m3u8?null='), ('61000', 'http://xxxxx.net/i/videos/vod/xxxxx/index_0_a.m3u8?null=')]
above is my list made of tuples, and I want to sort by first element. the way it should work is...
my_list.sort(key=lambda Lfloat(L[0])), reverse=True)
or my_list.sort(key=lambda L:float(L[0]), reverse=True)
or sorted(my_list, key=lambda L:float(L[0]), reverse=True)
Regardless of using reverse or substituting float with int, answer is same. My result comes up as 61000 tuple row, and it only shows 61000 tuple under log as list within list 61000,'xxxx' (wiki), nothing else. seriously what am I missing here?
I've searched and searched but can't find an answer for this sorting dilemma shown below which works in python 2.7.6 IDLE shell.
my_list = [('462000', 'http://xxxxx.net/i/videos/vod/xxxxx/index_0_av.m3u8?null='), ('862000', 'http://xxxxx.net/i/videos/vod/xxxxx/index_1_av.m3u8?null='), ('1378000', 'http://xxxxx.net/i/videos/vod/xxxxx/index_2_av.m3u8?null='), ('2074000', 'http://xxxxx.net/i/videos/vod/xxxxx/index_3_av.m3u8?null='), ('61000', 'http://xxxxx.net/i/videos/vod/xxxxx/index_0_a.m3u8?null=')]
above is my list made of tuples, and I want to sort by first element. the way it should work is...
my_list.sort(key=lambda Lfloat(L[0])), reverse=True)
or my_list.sort(key=lambda L:float(L[0]), reverse=True)
or sorted(my_list, key=lambda L:float(L[0]), reverse=True)
Regardless of using reverse or substituting float with int, answer is same. My result comes up as 61000 tuple row, and it only shows 61000 tuple under log as list within list 61000,'xxxx' (wiki), nothing else. seriously what am I missing here?