summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pygments/lexers/__init__.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/pygments/lexers/__init__.py b/pygments/lexers/__init__.py
index dbfe4351..20b484a7 100644
--- a/pygments/lexers/__init__.py
+++ b/pygments/lexers/__init__.py
@@ -188,7 +188,13 @@ def guess_lexer_for_filename(_fn, _text, **options):
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)