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 @@ -3074,19 +3074,20 @@ def _reorder_indexer(
3074
3074
-------
3075
3075
indexer : a sorted Int64Index indexer of self ordered as seq
3076
3076
"""
3077
- # Find out if the list_like label are sorted as the levels or not
3078
- need_sort = False
3079
- for i , k in enumerate (seq ):
3080
- if is_list_like (k ):
3081
- if not need_sort :
3082
- k_codes = self .levels [i ].get_indexer (k )
3083
- k_codes = k_codes [k_codes >= 0 ] # Filter absent keys
3084
- # True if the given codes are not ordered
3085
- need_sort = (k_codes [:- 1 ] > k_codes [1 :]).any ()
3086
- # Bail out if no need to sort
3087
- # This is only true for a lexsorted index
3088
- if not need_sort and self .is_lexsorted ():
3089
- return indexer
3077
+ # If the index is lexsorted and the list_like label in seq are sorted
3078
+ # then we do not need to sort
3079
+ if self .is_lexsorted ():
3080
+ need_sort = False
3081
+ for i , k in enumerate (seq ):
3082
+ if is_list_like (k ):
3083
+ if not need_sort :
3084
+ k_codes = self .levels [i ].get_indexer (k )
3085
+ k_codes = k_codes [k_codes >= 0 ] # Filter absent keys
3086
+ # True if the given codes are not ordered
3087
+ need_sort = (k_codes [:- 1 ] > k_codes [1 :]).any ()
3088
+ # Bail out if both index and seq are sorted
3089
+ if not need_sort :
3090
+ return indexer
3090
3091
3091
3092
n = len (self )
3092
3093
keys : Tuple [np .ndarray , ...] = tuple ()
You can’t perform that action at this time.
0 commit comments