cudf.core.column.lists.ListMethods.sort_values#

ListMethods.sort_values(ascending: bool = True, inplace: bool = False, kind: str = 'quicksort', na_position: str = 'last', ignore_index: bool = False) Union[Series, GenericIndex]#

Sort each list by the values.

Sort the lists in ascending or descending order by some criterion.

Parameters
ascendingbool, default True

If True, sort values in ascending order, otherwise descending.

na_position{‘first’, ‘last’}, default ‘last’

‘first’ puts nulls at the beginning, ‘last’ puts nulls at the end.

ignore_indexbool, default False

If True, the resulting axis will be labeled 0, 1, …, n - 1.

Returns
Series or Index with each list sorted

Notes

Difference from pandas:
  • Not supporting: inplace, kind

Examples

>>> s = cudf.Series([[4, 2, None, 9], [8, 8, 2], [2, 1]])
>>> s.list.sort_values(ascending=True, na_position="last")
0    [2.0, 4.0, 9.0, nan]
1         [2.0, 8.0, 8.0]
2              [1.0, 2.0]
dtype: list