From e3e5be460e9c79fd8d9e82287ffea2f106bb6767 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Degr=C3=A9mont?= <1502778+degremont@users.noreply.github.com> Date: Thu, 25 Jul 2024 21:10:21 +0200 Subject: [PATCH] Ticket #216: Don't sort None value (#220) 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. Co-authored-by: Aurelien Degremont --- 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)