@@ -1903,15 +1903,30 @@ def radix_sort(array, comp=lambda u, v: u <= v, **kwargs):
19031903 # Raise error if not Python backend
19041904 raise_if_backend_is_not_python (radix_sort , kwargs .get ('backend' , Backend .PYTHON ))
19051905
1906- # Filter out None values
1907- array = [x for x in array if x is not None ]
1908-
1909- # Get maximum number to determine number of digits
1910- max_val = max (array ) if array else 0
1906+ start = kwargs .get ('start' , 0 )
1907+ end = kwargs .get ('end' , len (array ) - 1 )
1908+
1909+ # Handle sub-array selection if start and end are provided
1910+ sub_array = array [start :end + 1 ]
1911+
1912+ # Remove None values from sub_array before sorting
1913+ sub_array = [x for x in sub_array if x is not None ]
1914+
1915+ # Get maximum value to determine the number of digits
1916+ max_val = max (sub_array ) if sub_array else 0
19111917 exp = 1
19121918 while max_val // exp > 0 :
1913- _count_sort_for_radix (array , exp , comp )
1919+ _count_sort_for_radix (sub_array , exp , comp )
19141920 exp *= 10
19151921
1922+ index = 0
1923+ for i in range (start , end + 1 ):
1924+ if array [i ] is None :
1925+ continue
1926+ array [i ] = sub_array [index ]
1927+ index += 1
1928+
19161929 if _check_type (array , (DynamicArray , _arrays .DynamicOneDimensionalArray )):
1917- array ._modify (True )
1930+ array ._modify (True )
1931+
1932+ return array
0 commit comments