File tree Expand file tree Collapse file tree 1 file changed +14
-13
lines changed Expand file tree Collapse file tree 1 file changed +14
-13
lines changed Original file line number Diff line number Diff line change @@ -3103,19 +3103,20 @@ def _reorder_indexer(
3103
3103
-------
3104
3104
indexer : a sorted Int64Index indexer of self ordered as seq
3105
3105
"""
3106
- # Find out if the list_like label are sorted as the levels or not
3107
- need_sort = False
3108
- for i , k in enumerate (seq ):
3109
- if is_list_like (k ):
3110
- if not need_sort :
3111
- k_codes = self .levels [i ].get_indexer (k )
3112
- k_codes = k_codes [k_codes >= 0 ] # Filter absent keys
3113
- # True if the given codes are not ordered
3114
- need_sort = (k_codes [:- 1 ] > k_codes [1 :]).any ()
3115
- # Bail out if no need to sort
3116
- # This is only true for a lexsorted index
3117
- if not need_sort and self .is_lexsorted ():
3118
- return indexer
3106
+ # If the index is lexsorted and the list_like label in seq are sorted
3107
+ # then we do not need to sort
3108
+ if self .is_lexsorted ():
3109
+ need_sort = False
3110
+ for i , k in enumerate (seq ):
3111
+ if is_list_like (k ):
3112
+ if not need_sort :
3113
+ k_codes = self .levels [i ].get_indexer (k )
3114
+ k_codes = k_codes [k_codes >= 0 ] # Filter absent keys
3115
+ # True if the given codes are not ordered
3116
+ need_sort = (k_codes [:- 1 ] > k_codes [1 :]).any ()
3117
+ # Bail out if both index and seq are sorted
3118
+ if not need_sort :
3119
+ return indexer
3119
3120
3120
3121
n = len (self )
3121
3122
keys : Tuple [np .ndarray , ...] = tuple ()
You can’t perform that action at this time.
0 commit comments