cudf.DataFrame.sort_values#

DataFrame.sort_values(by, axis=0, ascending=True, inplace=False, kind='quicksort', na_position='last', ignore_index=False, key=None)[source]#

Sort by the values along either axis.

Parameters:
bystr or list of str

Name or list of names to sort by.

ascendingbool or list of bool, default True

Sort ascending vs. descending. Specify list for multiple sort orders. If this is a list of bools, must match the length of the by.

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

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

ignore_indexbool, default False

If True, index will not be sorted.

keycallable, optional

Apply the key function to the values before sorting. This is similar to the key argument in the builtin sorted function, with the notable difference that this key function should be vectorized. It should expect a Series and return a Series with the same shape as the input. It will be applied to each column in by independently. Currently not supported.

Returns:
FrameFrame with sorted values.

Examples

>>> import cudf
>>> df = cudf.DataFrame()
>>> df['a'] = [0, 1, 2]
>>> df['b'] = [-3, 2, 0]
>>> df.sort_values('b')
   a  b
0  0 -3
2  2  0
1  1  2

Pandas Compatibility Note

pandas.DataFrame.sort_values(), pandas.Series.sort_values()

  • Support axis=’index’ only.

  • Not supporting: inplace, kind