From 1dafc62fda14e14c84e94250cc0906d68d91a1ce Mon Sep 17 00:00:00 2001 From: Connor Nelson Date: Wed, 16 Jun 2021 11:54:31 -0400 Subject: [PATCH] Sort challenges by id (#1914) * Sort challenges by ID as well as value in `/api/v1/challenges` to better standardize API output --- CTFd/api/v1/challenges.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CTFd/api/v1/challenges.py b/CTFd/api/v1/challenges.py index 1dbe7f58..36c583df 100644 --- a/CTFd/api/v1/challenges.py +++ b/CTFd/api/v1/challenges.py @@ -227,7 +227,9 @@ class ChallengeList(Resource): and_(Challenges.state != "hidden", Challenges.state != "locked") ) chal_q = ( - chal_q.filter_by(**query_args).filter(*filters).order_by(Challenges.value) + chal_q.filter_by(**query_args) + .filter(*filters) + .order_by(Challenges.value, Challenges.id) ) # Iterate through the list of challenges, adding to the object which