mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Merge pull request #14389 from pvanheus/add_sort_order_to_sortby_filter
Allow sort order for sort_by to be reversed
This commit is contained in:
@@ -4676,10 +4676,10 @@ In both cases the desired metadata is selected by ``key``.
|
||||
|
||||
The ``static_value`` and ``regexp`` filters can be inverted by setting ``keep`` to true.
|
||||
|
||||
* ``add_value``: add an option with a given ``name`` and ``value`` to the options. By default the new option is appended, with ``index`` the insertion position can be specified.
|
||||
* ``remove_value``: remove a value from the options. Either specified explicitly with ``value``, the value of another input specifified with ``ref``, or the metatdata ``key`` of another input ``meta_ref``.
|
||||
* ``add_value``: add an option with a given ``name`` and ``value`` to the options. By default, the new option is appended, with ``index`` the insertion position can be specified.
|
||||
* ``remove_value``: remove a value from the options. Either specified explicitly with ``value``, the value of another input specified with ``ref``, or the metadata ``key`` of another input ``meta_ref``.
|
||||
* ``unique_value``: remove options that have duplicate entries in the given ``column``.
|
||||
* ``sort_by``: sort options by the entries of a given ``column``.
|
||||
* ``sort_by``: sort options by the entries of a given ``column``. If ``reverse_sort_order`` is set to ``true``, reverse sort order from ascending to descending.
|
||||
* ``multiple_splitter``: split the entries of the specified ``column``(s) in the referenced file using a ``separator``. Thereby the number of columns is increased.
|
||||
|
||||
### Examples
|
||||
@@ -4868,6 +4868,13 @@ added to the end of the list.</xs:documentation>
|
||||
from the list.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="reverse_sort_order" type="xs:boolean" default="false">
|
||||
<xs:annotation>
|
||||
<xs:documentation xml:lang="en">Used when ``type`` is ``sort_by``, if set to
|
||||
``true`` it will reverse the sort order from ascending to descending. Default
|
||||
is ``false``.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
</xs:complexType>
|
||||
<xs:complexType name="Outputs">
|
||||
<xs:annotation>
|
||||
|
||||
@@ -516,9 +516,10 @@ class SortByColumnFilter(Filter):
|
||||
column = elem.get("column", None)
|
||||
assert column is not None, "Required 'column' attribute missing from filter"
|
||||
self.column = d_option.column_spec_to_index(column)
|
||||
self.reverse = string_as_bool(elem.get("reverse_sort_order", "False"))
|
||||
|
||||
def filter_options(self, options, trans, other_values):
|
||||
return sorted(options, key=lambda x: x[self.column])
|
||||
return sorted(options, key=lambda x: x[self.column], reverse=self.reverse)
|
||||
|
||||
|
||||
filter_types = dict(
|
||||
|
||||
Reference in New Issue
Block a user