diff --git a/beets/autotag/hooks.py b/beets/autotag/hooks.py index 1c0408e2f..3de803899 100644 --- a/beets/autotag/hooks.py +++ b/beets/autotag/hooks.py @@ -349,8 +349,10 @@ class Distance(object): # Convert distance into a negative float we can sort items in # ascending order (for keys, when the penalty is equal) and # still get the items with the biggest distance first. - return sorted(list_, - key=lambda key_dist: (0 - key_dist[1], key_dist[0])) + return sorted( + list_, + key=lambda key_and_dist: (-key_and_dist[1], key_and_dist[0]) + ) # Behave like a float. diff --git a/beets/ui/commands.py b/beets/ui/commands.py index 2d9f3cdb1..3f55d864e 100644 --- a/beets/ui/commands.py +++ b/beets/ui/commands.py @@ -280,7 +280,7 @@ def show_change(cur_artist, cur_album, match): # Tracks. pairs = match.mapping.items() - pairs.sort(key=lambda __track_info: __track_info[1].index) + pairs.sort(key=lambda item_and_track_info: item_and_track_info[1].index) # Build up LHS and RHS for track difference display. The `lines` list # contains ``(lhs, rhs, width)`` tuples where `width` is the length (in @@ -441,8 +441,10 @@ def summarize_items(items, singleton): summary_parts.append(items[0].format) else: # Enumerate all the formats by decreasing frequencies: - for fmt, count in sorted(format_counts.items(), - key=lambda f_c: (-f_c[1], f_c[0])): + for fmt, count in sorted( + format_counts.items(), + key=lambda fmt_and_count: (-fmt_and_count[1], fmt_and_count[0]) + ): summary_parts.append('{0} {1}'.format(fmt, count)) if items: