From d10c9b4ceaa0d2277866408f8b79e675505c7194 Mon Sep 17 00:00:00 2001 From: lethliel Date: Tue, 16 Apr 2019 15:18:04 +0200 Subject: [PATCH] [python3] fix sorting when using osc se osc se did not sort the output anymore. The logic in the existing results.sort(key=...) was wrong. Now it is using key=itemgetter(0,1) has two columns and key=itemgetter(0) if there is only one column. --- osc/commandline.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/osc/commandline.py b/osc/commandline.py index 89d23dac..824d2b14 100644 --- a/osc/commandline.py +++ b/osc/commandline.py @@ -34,6 +34,8 @@ try: except ImportError: from .util.helper import cmp_to_key +from operator import itemgetter + MAN_HEADER = r""".TH %(ucname)s "1" "%(date)s" "%(name)s %(version)s" "User Commands" .SH NAME %(name)s \- openSUSE build service command-line tool. @@ -7741,11 +7743,12 @@ Please submit there instead, or use --nodevelproject to force direct submission. continue # construct a sorted, flat list # Sort by first column, follwed by second column if we have two columns, else sort by first. - # results.sort(lambda x, y: ( cmp(x[0], y[0]) or - # (len(x)>1 and len(y)>1 and cmp(x[1], y[1])) )) - results.sort(key=cmp_to_key(compare)) + if len(results[0]) > 1: + sorted_results = sorted(results, key=itemgetter(0,1)) + else: + sorted_results = sorted(results, key=itemgetter(0)) new = [] - for i in results: + for i in sorted_results: new.extend(i) results = new headline = []