Commits

Georg Brandl committed 2243bd0 Merge

Merged in goodwillcoding/pygments-main (pull request #229)

Make pygments.lexers.guess_lexer_for_filename py3 compatible.

Comments (0)

Files changed (1)

pygments/lexers/__init__.py

         if rv == 1.0:
             return lexer(**options)
         result.append((rv, lexer))
-    result.sort()
+
+    # since py3 can no longer sort by class name by default, here is the
+    # sorting function that works in both
+    def type_sort(type_):
+        return (type_[0], type_[1].__name__)
+    result.sort(key=type_sort)
+
     if not result[-1][0] and primary is not None:
         return primary(**options)
     return result[-1][1](**options)