From: Bernie Innocenti Date: Sun, 16 May 2010 13:18:43 +0000 (-0400) Subject: Add support for sorting glob results X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=9efa432b57111d0dda80034d151a0dad1204990f;p=geekigeeki.git Add support for sorting glob results Results can optionally be in reverse order (reverse=1) --- diff --git a/geekigeeki.py b/geekigeeki.py index 044c7bf..0427f9b 100755 --- a/geekigeeki.py +++ b/geekigeeki.py @@ -173,7 +173,7 @@ def link_inline(name, descr=None, kvargs={}): def link_inline_glob(pattern, descr=None, kvargs={}): if not url_re.match(pattern) and bool(set(pattern) & set('?*[')): s = '' - for name in glob.glob(pattern): + for name in sorted(glob.glob(pattern), reverse=bool(int(kvargs.get('reverse', '0'))) ): s += link_inline(name, descr, kvargs) return s else: