diff --git a/plugins/talks.py b/plugins/talks.py index 8339033..3e37d3e 100644 --- a/plugins/talks.py +++ b/plugins/talks.py @@ -180,11 +180,24 @@ class TalkListDirective(Directive): def run(self): lang = self.options.get('lang', 'C') tmpl = jinja_env().get_template('talk.html') + + def _sort_date(name): + ''' + This function is a helper to sort talks by start date + + When no date is available, put at the beginning + ''' + d = get_talk_data(name) + if 'time' in d: + return d['time'] + return datetime.datetime(1, 1, 1) + return [ nodes.raw('', tmpl.render(lang=lang, **get_talk_data(n)), format='html') - for n in get_talk_names() - ] + for n in sorted(get_talk_names(), + key=_sort_date) + ] class TalkDirective(Directive):