diff --git a/app/templates/todo/topics.html b/app/templates/todo/topics.html
index 2156e8d..8b39b8e 100644
--- a/app/templates/todo/topics.html
+++ b/app/templates/todo/topics.html
@@ -9,17 +9,28 @@ Topics to be Added
{% if current_user.rank.atLeast(current_user.rank.EDITOR) %}
{% if n >= 10000 %}
+ href="{{ url_for('todo_topics_page', q=query, show_discarded=show_discarded, n=100, sort=sort_by) }}">
Paginiated List
{% else %}
+ href="{{ url_for('todo_topics_page', q=query, show_discarded=show_discarded, n=10000, sort=sort_by) }}">
Unlimited List
{% endif %}
{% endif %}
-
+ {% if sort_by == "name" %}
+
+ Sort by date
+
+ {% else %}
+
+ Sort by name
+
+ {% endif %}
+
{% if not show_discarded %}
Show
{% else %}
diff --git a/app/views/packages/todo.py b/app/views/packages/todo.py
index baca000..2742f6d 100644
--- a/app/views/packages/todo.py
+++ b/app/views/packages/todo.py
@@ -63,7 +63,12 @@ def todo_topics_page():
total = query.count()
query = query.filter(~ db.exists().where(Package.forums==ForumTopic.topic_id)) \
- .order_by(db.asc(ForumTopic.wip), db.asc(ForumTopic.name), db.asc(ForumTopic.title))
+
+ sort_by = request.args.get("sort")
+ if sort_by == "name":
+ query = query.order_by(db.asc(ForumTopic.wip), db.asc(ForumTopic.name), db.asc(ForumTopic.title))
+ elif sort_by is None or sort_by == "date":
+ query = query.order_by(db.asc(ForumTopic.created_at))
topic_count = query.count()
@@ -85,4 +90,4 @@ def todo_topics_page():
return render_template("todo/topics.html", topics=query.items, total=total, \
topic_count=topic_count, query=search, show_discarded=show_discarded, \
next_url=next_url, prev_url=prev_url, page=page, page_max=query.pages, \
- n=num)
+ n=num, sort_by=sort_by)