summaryrefslogtreecommitdiff
path: root/coverage/summary.py
diff options
context:
space:
mode:
Diffstat (limited to 'coverage/summary.py')
-rw-r--r--coverage/summary.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/coverage/summary.py b/coverage/summary.py
index 97d9fff0..986cd2f2 100644
--- a/coverage/summary.py
+++ b/coverage/summary.py
@@ -104,10 +104,18 @@ class SummaryReporter(object):
# Sort the lines and write them out.
if getattr(self.config, 'sort', None):
- position = column_order.get(self.config.sort.lower())
+ sort_option = self.config.sort.lower()
+ reverse = False
+ if sort_option[0] == '-':
+ reverse = True
+ sort_option = sort_option[1:]
+ elif sort_option[0] == '+':
+ sort_option = sort_option[1:]
+
+ position = column_order.get(sort_option)
if position is None:
raise CoverageException("Invalid sorting option: {!r}".format(self.config.sort))
- lines.sort(key=lambda l: (l[1][position], l[0]))
+ lines.sort(key=lambda l: (l[1][position], l[0]), reverse=reverse)
for line in lines:
self.writeout(line[0])