Sort the fields in place.
This method has exactly the same functionality as the built-in list.sort method.
The sort is stable in that if multiple fields have the same key value then their original order is preserved.
Parameters: |
|
---|---|
Returns: | None |
Examples: |
Two ways of sorting by standard name:
>>> fl.sort(key=lambda f: f.standard_name)
>>> from operator import attrgetter
>>> fl.sort(key=attrgetter('standard_name'))
Place the fields in reverse standard name order:
>>> from operator import attrgetter
>>> fl.sort(key=attrgetter('standard_name'), reverse=True)
Sort by standard name then by long name:
>>> from operator import attrgetter
>>> fl.sort(key=attrgetter('standard_name', 'long_name'))
Sort by standard name then by the value of the second element of the data array:
>>> fl.sort(key=lambda f: (f.standard_name, f.datum(1)))
Sort by reverse order of the first time coordinate value:
>>> fl.sort(key=lambda f: f.coord('T').Data[0], reverse=True)