Skip to content

Latest commit

 

History

History
76 lines (53 loc) · 3.09 KB

sort.rst

File metadata and controls

76 lines (53 loc) · 3.09 KB

sort

.. py:function:: sort(fs, [keys, [orders]], ascending=True)
.. py:function:: Fieldset.sort([keys, [orders]], ascending=True)
   :noindex:

   Sorts ``fs`` according to the specified options.

   :param fs: input fieldset
   :type fs: :class:`Fieldset`
   :param keys: sorting key(s), they must be valid ecCodes keys
   :type keys: str or list
   :param orders: sorting order(s)
   :type orders: str or list
   :param ascending: sort ascending vs. descending. Specify list for multiple sort orders. If this is a list of bools, must match the length of the ``keys``.
   :type ascending: bool or list of bool
   :rtype: :class:`Fieldset`

   If no ``keys`` are specified the sorting is performed by the following ecCodes keys in the specified order:

      * date
      * time
      * step
      * number
      * level
      * paramId

   Here **number** is the ENS forecast member number.

   If ``keys`` are specified (either as a list or a str) they define the sorting keys (they must be valid ecCodes keys).

   The optional ``ascending`` can specify the ascending/descending sorting direction. ``ascending`` can be either a bool or a list of bool:

   * if it is a str the sorting direction applies to all the ``keys``
   * if it is a list ``keys`` must also be a list with the same number of elements - the sorting directions apply to each sorting key specified.

   The sorting direction can also be expressed by the optional ``orders``: ">" means descending, while "<" means ascending order. It cannot be used together with ``ascending``. ``orders`` can be either a str or a list:

   * if it is a str the sorting direction applies to all the ``keys``
   * if it is a list ``keys`` must also be a list with the same number of elements - the sorting directions apply to each sorting key specified.


.. mv-minigallery:: sort