Georg Brandl  committed 2243bd0 Merge

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

Make pygments.lexers.guess_lexer_for_filename py3 compatible.

  • Participants
  • Parent commits 0442d3c, c31841d
  • Branches default

Comments (0)

Files changed (1)

File pygments/lexers/

         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)