diff --git a/beets/ui/commands.py b/beets/ui/commands.py index bf38c5c2c..7dc54b953 100644 --- a/beets/ui/commands.py +++ b/beets/ui/commands.py @@ -437,8 +437,9 @@ def summarize_items(items, singleton): # A single format. summary_parts.append(items[0].format) else: - # Enumerate all the formats. - for fmt, count in format_counts.iteritems(): + # Enumerate all the formats by decreasing frequencies: + for fmt, count in sorted(format_counts.items(), + key=lambda (f, c): (-c, f)): summary_parts.append('{0} {1}'.format(fmt, count)) if items: diff --git a/test/test_ui.py b/test/test_ui.py index 181ee25f6..14cb4081f 100644 --- a/test/test_ui.py +++ b/test/test_ui.py @@ -1005,7 +1005,10 @@ class SummarizeItemsTest(_common.TestCase): i2.format = "G" summary = commands.summarize_items([self.item, i2], False) - self.assertEqual(summary, "2 items, G 1, F 1, 4kbps, 21:48, 1.9 KB") + self.assertEqual(summary, "2 items, F 1, G 1, 4kbps, 21:48, 1.9 KB") + + summary = commands.summarize_items([self.item, i2, i2], False) + self.assertEqual(summary, "3 items, G 2, F 1, 4kbps, 32:42, 2.9 KB") class PathFormatTest(_common.TestCase):