diff --git a/server.py b/server.py
index 2bb1a7e1e6f1ec88fd74bb7e48edde0ad9dafd6f..d7721e714c45a155a425b0bba66c5c14f279122d 100755
--- a/server.py
+++ b/server.py
@@ -154,7 +154,7 @@ def index():
 @app.route('/course')
 @register_navbar('Videos', icon='film')
 def courses():
-	courses = query('SELECT * FROM courses WHERE (? OR (visible AND listed))', ismod())
+	courses = query('SELECT * FROM courses WHERE (? OR (visible AND listed)) ORDER BY title', ismod())
 	for course in courses:
 		if course['semester'] == '':
 			course['semester'] = 'zeitlos'
@@ -171,16 +171,16 @@ def course(id=None, handle=None):
 		course = query('SELECT * FROM courses WHERE id = ? AND (? OR visible)', id, ismod())[0]
 	else:
 		course = query('SELECT * FROM courses WHERE handle = ? AND (? OR visible)', handle, ismod())[0]
-	course['auth'] = query('SELECT * FROM auth WHERE course_id = ?', course['id'])
-	auths = query('SELECT auth.* FROM auth JOIN lectures ON (auth.lecture_id = lectures.id) WHERE lectures.course_id = ?', course['id'])
-	lectures = query('SELECT * FROM lectures WHERE course_id = ? AND (? OR visible)', course['id'], ismod())
+	course['auth'] = query('SELECT * FROM auth WHERE course_id = ? ORDER BY auth_type', course['id'])
+	auths = query('SELECT auth.* FROM auth JOIN lectures ON (auth.lecture_id = lectures.id) WHERE lectures.course_id = ? ORDER BY auth.auth_type', course['id'])
+	lectures = query('SELECT * FROM lectures WHERE course_id = ? AND (? OR visible) ORDER BY time, duration DESC', course['id'], ismod())
 	for lecture in lectures:
 		lecture['auth'] = []
 		for auth in auths:
 			if auth['lecture_id'] == lecture['id']:
 				lecture['auth'].append(auth)
 	videos = query('''
-			SELECT videos.*, (videos.downloadable AND courses.downloadable) as downloadable, formats.description AS format_description
+			SELECT videos.*, (videos.downloadable AND courses.downloadable) as downloadable, formats.description AS format_description, formats.player_prio, formats.prio
 			FROM videos
 			JOIN lectures ON (videos.lecture_id = lectures.id)
 			JOIN formats ON (videos.video_format = formats.id)
@@ -199,7 +199,7 @@ def faq():
 @handle_errors('course', 'Diese Vorlesung existiert nicht!', 404, IndexError)
 def lecture(id):
 	lectures = query('SELECT * FROM lectures WHERE id = ? AND (? OR visible)', id, ismod())
-	videos = query('SELECT videos.*, formats.description AS format_description FROM videos JOIN formats ON (videos.video_format = formats.id) WHERE lecture_id = ? AND (? OR visible)', id, ismod())
+	videos = query('SELECT videos.*, formats.description AS format_description, formats.prio, formats.player_prio FROM videos JOIN formats ON (videos.video_format = formats.id) WHERE lecture_id = ? AND (? OR visible)', id, ismod())
 	if not videos:
 		flash('Zu dieser Vorlesung wurden noch keine Videos veröffentlicht!')
 	courses = query('SELECT * FROM courses WHERE id = ? AND (? OR (visible AND listed))', lectures[0]['course_id'], ismod())
@@ -359,7 +359,7 @@ def stats():
 @register_navbar('Changelog', 'book')
 @mod_required
 def changelog():
-	changelog = query('SELECT *, ( "table" || "." || id_value || "." ||field) as path FROM changelog LEFT JOIN users ON (changelog.who = users.id) ORDER BY "when" DESC LIMIT 50')
+	changelog = query('SELECT *, ( "table" || "." || id_value || "." ||field) as path FROM changelog LEFT JOIN users ON (changelog.who = users.id) ORDER BY `when` DESC LIMIT 50')
 	return render_template('changelog.html', changelog=changelog)
 
 @app.route('/files/<filename>')
diff --git a/templates/macros.html b/templates/macros.html
index e86c344509ba3ee8f339f763360f728b870ebfc0..6e1b722e8e154c9b9bfc7c5113773e77233fdced 100644
--- a/templates/macros.html
+++ b/templates/macros.html
@@ -46,7 +46,7 @@
 <script src="{{url_for('static', filename='mediaelementjs/mep-feature-sourcechooser.js')}}"></script>
 <link rel="stylesheet" href="{{url_for('static', filename='mediaelementjs/mediaelementplayer.css')}}"/>
 <video class="player" width="640" height="360" style="width: 100%; height: 100%;" controls="controls">
-	{% for v in videos %}
+	{% for v in videos|sort(attribute='player_prio', reverse=True) %}
 		<source type="video/mp4" src="{{ config.VIDEOPREFIX }}/{{ v.path }}" title="{{ v.format_description }}"/>
 	{% endfor %}
 </video>
@@ -90,7 +90,7 @@
 {% macro video_download_btn(videos) %}
 <span class="btn btn-primary dropdown-toggle{% if videos|length is equalto 0 %} disabled{% endif %}" type="button" data-toggle="dropdown">Download <span class="caret"></span></span>
 <ul class="dropdown-menu">
-	{% for v in videos %}
+	{% for v in videos|sort(attribute='prio', reverse=True) %}
 		{% if v.downloadable %}	
 			<li><a href="{{ config.VIDEOPREFIX }}/{{v.path}}">{{ valuecheckbox(['videos',v.id,'visible'], v.visible) }} {{v.format_description}} ({{v.file_size|filesizeformat(true)}})</a></li>
 		{% endif %}
@@ -98,7 +98,7 @@
 </ul>
 <noscript>
 	<ul class="pull-right list-unstyled" style="margin-left:10px;">
-		{% for v in videos %}
+		{% for v in videos|sort(attribute='prio', reverse=True) %}
 		<li><a href="{{ config.VIDEOPREFIX }}/{{v.path}}">{{v.format_description}} ({{v.file_size|filesizeformat(true)}})</a></li>
 		{% endfor %}
 	</ul>