@@ -2390,6 +2390,7 @@ def sort_index(
23902390 * ,
23912391 ascending : bool = ...,
23922392 inplace : Literal [False ] = ...,
2393+ kind : str = ...,
23932394 na_position : Literal ["first" , "last" ] = ...,
23942395 ) -> DataFrame :
23952396 ...
@@ -2400,6 +2401,7 @@ def sort_index(
24002401 * ,
24012402 ascending : bool = ...,
24022403 inplace : Literal [True ] = ...,
2404+ kind : str = ...,
24032405 na_position : Literal ["first" , "last" ] = ...,
24042406 ) -> None :
24052407 ...
@@ -2410,6 +2412,7 @@ def sort_index(
24102412 axis : Union [int , str ] = 0 ,
24112413 ascending : bool = True ,
24122414 inplace : bool = False ,
2415+ kind : str | None = None ,
24132416 na_position : Literal ["first" , "last" ] = "last" ,
24142417 ) -> Optional [DataFrame ]:
24152418 if utils .get_axis_number (axis ) == 0 :
@@ -2423,7 +2426,8 @@ def sort_index(
24232426 else order .descending_over (column , na_last )
24242427 for column in index_columns
24252428 ]
2426- block = self ._block .order_by (ordering )
2429+ is_stable = (kind or constants .DEFAULT_SORT_KIND ) in ["stable" , "mergesort" ]
2430+ block = self ._block .order_by (ordering , stable = is_stable )
24272431 else : # axis=1
24282432 _ , indexer = self .columns .sort_values (
24292433 return_indexer = True , ascending = ascending , na_position = na_position # type: ignore
@@ -2467,7 +2471,7 @@ def sort_values(
24672471 * ,
24682472 inplace : bool = False ,
24692473 ascending : bool | typing .Sequence [bool ] = True ,
2470- kind : str = "quicksort" ,
2474+ kind : str | None = None ,
24712475 na_position : typing .Literal ["first" , "last" ] = "last" ,
24722476 ) -> Optional [DataFrame ]:
24732477 if isinstance (by , (bigframes .series .Series , indexes .Index , DataFrame )):
@@ -2499,7 +2503,8 @@ def sort_values(
24992503 if is_ascending
25002504 else order .descending_over (column_id , na_last )
25012505 )
2502- block = self ._block .order_by (ordering )
2506+ is_stable = (kind or constants .DEFAULT_SORT_KIND ) in ["stable" , "mergesort" ]
2507+ block = self ._block .order_by (ordering , stable = is_stable )
25032508 if inplace :
25042509 self ._set_block (block )
25052510 return None
0 commit comments