mirror of
https://github.com/volatilityfoundation/volatility3.git
synced 2026-09-13 21:27:39 +02:00
Allow for ascending or descending sort order.
This commit is contained in:
@@ -27,6 +27,8 @@ class Renderer(validity.ValidityRoutines, metaclass = ABCMeta):
|
||||
|
||||
|
||||
class ColumnSortKey(metaclass = ABCMeta):
|
||||
ascending = True
|
||||
|
||||
@abstractmethod
|
||||
def key(self, values):
|
||||
"""The key function passed as a sort key to the TreeGrid's visit function"""
|
||||
|
||||
@@ -255,13 +255,16 @@ class TreeGrid(interfaces.renderers.TreeGrid):
|
||||
accumulator = function(n, accumulator)
|
||||
if sort_key is not None:
|
||||
children = sorted(children, key = lambda x: sort_key(x[0].values))
|
||||
if not sort_key.ascending:
|
||||
children = reversed(children)
|
||||
accumulator = self._visit(children, function, accumulator, sort_key)
|
||||
return accumulator
|
||||
|
||||
|
||||
class ColumnSortKey(interfaces.renderers.ColumnSortKey):
|
||||
def __init__(self, treegrid, column_name):
|
||||
def __init__(self, treegrid, column_name, ascending = True):
|
||||
self._index = None
|
||||
self.ascending = ascending
|
||||
for i in treegrid.columns:
|
||||
if i.name.lower() == column_name.lower():
|
||||
self._index = i.index
|
||||
|
||||
Reference in New Issue
Block a user