Sort the elements in place.
The sort is stable which means that when multiple records have the same key, 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'))
Get the elements in reverse standard name order:
>>> fl.sort(key=attrgetter('standard_name'), reverse=True)
Sort by standard name then by the value of the first element of the data array:
>>> fl.sort(key=attrgetter('standard_name', 'first_datum'))
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.subspace[..., 1].first_datum))