Skip to content

Commit af60d93

Browse files
author
y-p
committed
CLN: clarify series.order() logic
1 parent 862e5ea commit af60d93

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

pandas/core/series.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2138,13 +2138,15 @@ def order(self, na_last=True, ascending=True, kind='mergesort'):
21382138
-------
21392139
y : Series
21402140
"""
2141-
def _try_mergesort(arr):
2141+
def _try_kind_sort(arr):
21422142
# easier to ask forgiveness than permission
21432143
try:
2144+
# if kind==mergesort, it can fail for object dtype
21442145
return arr.argsort(kind=kind)
21452146
except TypeError:
21462147
# stable sort not available for object dtype
2147-
return arr.argsort()
2148+
# uses the argsort default quicksort
2149+
return arr.argsort(kind='quicksort')
21482150

21492151
arr = self.values
21502152
sortedIdx = pa.empty(len(self), dtype=np.int32)
@@ -2154,7 +2156,7 @@ def _try_mergesort(arr):
21542156
good = -bad
21552157
idx = pa.arange(len(self))
21562158

2157-
argsorted = _try_mergesort(arr[good])
2159+
argsorted = _try_kind_sort(arr[good])
21582160

21592161
if not ascending:
21602162
argsorted = argsorted[::-1]

0 commit comments

Comments
 (0)