2
0
mirror of https://github.com/xcat2/confluent.git synced 2024-11-23 01:53:28 +00:00

Add natural sort

For output groups with equivalent node counts, sort naturally
by the group text header.
This commit is contained in:
Jarrod Johnson 2017-09-22 09:54:28 -04:00
parent c966b09581
commit a0802dd66e

View File

@ -127,10 +127,21 @@ class GroupedData(object):
self.generate_byoutput()
modaloutput = None
ismodal = True
outdatalist = sorted(
self.byoutput, key=lambda x: len(self.byoutput[x]))
if not reverse:
outdatalist = reversed(outdatalist)
if reverse:
outdatalist = sorted(
self.byoutput, key=lambda x: [len(self.byoutput[x]),
humanify_nodename(
self.get_group_text(
self.byoutput[x]
))])
else:
outdatalist = sorted(
self.byoutput, key=lambda x: [0 - len(self.byoutput[x]),
humanify_nodename(
self.get_group_text(
self.byoutput[x]
))])
if reverse and skipmodal:
# if reversed, the last is biggest and should be skipped if modal
outdatalist = outdatalist[:-1]
@ -157,8 +168,12 @@ class GroupedData(object):
modaloutput = None
ismodal = True
revoutput = []
for outdata in reversed(
sorted(self.byoutput, key=lambda x: len(self.byoutput[x]))):
for outdata in sorted(
self.byoutput, key=lambda x: [0 - len(self.byoutput[x]),
humanify_nodename(
self.get_group_text(
self.byoutput[x]
))]):
if modaloutput is None:
modaloutput = outdata
if skipmodal: