because controversial is either 0 or 1 sort it by dislikes

This commit is contained in:
bassdart 2019-03-17 01:55:56 +01:00
parent 75f286828e
commit 822f4faff2

View file

@ -706,10 +706,17 @@ def sortTitlesBy(limit, sort, start):
modus = channel modus = channel
else: else:
modus = 'all' 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 if mycount != "" and mycount == "controversial":
# But then the second sorting, by title would be reversed also # controversial is either 0 or 1 so it does not makes sense to sort upon it
result = sorted(result, key = lambda i: (-1*float(i[mycount]), i['title'])) # 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) # itemgetter, should be faster (hm, but does'nt work: ValueError: could not convert string to float: pcount)
# importing "operator" for implementing itemgetter # importing "operator" for implementing itemgetter
#from operator import itemgetter #from operator import itemgetter