sort by comments in the database

master
atrc445 2021-08-22 13:33:13 +02:00
parent f14eda2f7a
commit 663363b041
1 changed files with 2 additions and 2 deletions

View File

@ -136,7 +136,7 @@ def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, filter_words='
elif sort == "bottom":
posts = sorted(posts.all(), key=lambda x: x.score)
elif sort == "comments":
posts = sorted(posts.all(), key=lambda x: x.comment_count, reverse=True)
posts = posts.order_by(Submission.comment_count.desc()).all()
elif sort == "random":
posts = posts.all()
posts = random.sample(posts, k=len(posts))