@@ -1903,15 +1903,30 @@ def radix_sort(array, comp=lambda u, v: u <= v, **kwargs):
1903
1903
# Raise error if not Python backend
1904
1904
raise_if_backend_is_not_python (radix_sort , kwargs .get ('backend' , Backend .PYTHON ))
1905
1905
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
1911
1917
exp = 1
1912
1918
while max_val // exp > 0 :
1913
- _count_sort_for_radix (array , exp , comp )
1919
+ _count_sort_for_radix (sub_array , exp , comp )
1914
1920
exp *= 10
1915
1921
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
+
1916
1929
if _check_type (array , (DynamicArray , _arrays .DynamicOneDimensionalArray )):
1917
- array ._modify (True )
1930
+ array ._modify (True )
1931
+
1932
+ return array
0 commit comments