Add support for sorting glob results
authorBernie Innocenti <bernie@codewiz.org>
Sun, 16 May 2010 13:18:43 +0000 (09:18 -0400)
committerBernie Innocenti <bernie@codewiz.org>
Sun, 16 May 2010 13:18:43 +0000 (09:18 -0400)
Results can optionally be in reverse order (reverse=1)

geekigeeki.py

index 044c7bfa55600abaebbee95d59a2b307fb1e0bd4..0427f9b3a4f40e538a256bede1ffb7cb4e7b47b5 100755 (executable)
@@ -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: