because controversial is either 0 or 1 sort it by dislikes
This commit is contained in:
parent
75f286828e
commit
822f4faff2
1 changed files with 11 additions and 4 deletions
11
default.py
11
default.py
|
@ -706,9 +706,16 @@ 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 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
|
# If count would'nt be negated one had to use reverse=true
|
||||||
# But then the second sorting, by title would be reversed also
|
# 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']))
|
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
|
||||||
|
|
Loading…
Reference in a new issue