Sort by the values.

Sort a Series in ascending or descending order by some criterion.

param axis
{0 or ‘index’}, default 0

Axis to direct sorting. The value ‘index’ is accepted for compatibility with DataFrame.sort_values.

param ascending
bool, default True

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

param inplace
bool, default False

If True, perform operation in-place.

param kind
{‘quicksort’, ‘mergesort’ or ‘heapsort’}, default ‘quicksort’

Choice of sorting algorithm. See also numpy.sort() for more information. ‘mergesort’ is the only stable algorithm.

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

Argument ‘first’ puts NaNs at the beginning, ‘last’ puts NaNs at the end.


Series Series ordered by values.


  • Parameter inplace is supported only with default value False.

  • Parameter axis is currently unsupported by Intel Scalable Dataframe Compiler.

  • Parameter kind is supported only with values 'mergesort' and 'quicksort'.

  • This function may reveal slower performance than Pandas* on user system. Users should exercise a tradeoff

    between staying in JIT-region with that function or going back to interpreter mode.


Sort by the values.
import numpy as np
import pandas as pd
from numba import njit

def series_sort_values():
    series = pd.Series([3, -10, np.nan, 0, 92])

    return series.sort_values()

$ python ./series/
1   -10.0
3     0.0
0     3.0
4    92.0
2     NaN
dtype: float64

See also


Sort by the Series indices.


Sort DataFrame by the values along either axis.


Sort DataFrame by indices.