From f6dd3f17661dd61023e6b2c0678fa73124ac7382 Mon Sep 17 00:00:00 2001 From: Aurelien Degremont Date: Fri, 29 Nov 2019 04:08:44 -0500 Subject: [PATCH] Ticket #216: Don't sort None value In Shine.CLI.Display, instead of returning None when sorting without sorting parameter, just don't sort at all. Avoid trying to sort and compare None value with is no more sortable. --- lib/Shine/CLI/Display.py | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/lib/Shine/CLI/Display.py b/lib/Shine/CLI/Display.py index 9f87098..36d258a 100644 --- a/lib/Shine/CLI/Display.py +++ b/lib/Shine/CLI/Display.py @@ -156,17 +156,10 @@ def fieldvals(comp): comps.groupby(key=fieldvals) ] # Sort - def sorter(compgrp): - """ - Sort grplist based on provided sort_key for the first element of - compgrp. - """ - (first, _) = compgrp - if sort_key is None: - return None - return sort_key(first) - - for first, compgrp in sorted(grplst, key=sorter): + if sort_key is not None: + grplst.sort(key=lambda group: sort_key(group[0])) + + for first, compgrp in grplst: # Get component fields fields = _get_fields(first, pat_fields)