diff --git a/default.py b/default.py index 47e5678..d0b193f 100644 --- a/default.py +++ b/default.py @@ -706,10 +706,17 @@ def sortTitlesBy(limit, sort, start): modus = channel else: modus = 'all' - # sort by negated count first and then by title in lexical order. - # If count would'nt be negated one had to use reverse=true - # But then the second sorting, by title would be reversed also - result = sorted(result, key = lambda i: (-1*float(i[mycount]), i['title'])) + + if mycount != "" and mycount == "controversial": + # controversial is either 0 or 1 so it does not makes sense to sort upon it + # instead sort videos considered controversial by dislikes + # change controversial in videos.json to a float? + result = sorted(result, key = lambda i: (-1*float(i['dislikes']), i['title'])) + else: + # If count would'nt be negated one had to use reverse=true + # but then the second sorting, by title would be reversed also + # sort by negated count first and then by title in lexical order. + result = sorted(result, key = lambda i: (-1*float(i[mycount]), i['title'])) # itemgetter, should be faster (hm, but does'nt work: ValueError: could not convert string to float: pcount) # importing "operator" for implementing itemgetter #from operator import itemgetter