diff --git a/volatility/framework/interfaces/renderers.py b/volatility/framework/interfaces/renderers.py index 127ca044a..a0480a834 100644 --- a/volatility/framework/interfaces/renderers.py +++ b/volatility/framework/interfaces/renderers.py @@ -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""" diff --git a/volatility/framework/renderers/__init__.py b/volatility/framework/renderers/__init__.py index de674c5fc..dc71e5d1e 100644 --- a/volatility/framework/renderers/__init__.py +++ b/volatility/framework/renderers/__init__.py @@ -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