sorted_array=[]
for i in range(len(buckets)):
buckets[i].sort()
for j in range(len(buckets[i])):
sorted_array.append(buckets[i][j])
return sorted_array
After Change
min_value, max_value = (min(my_list), max(my_list))
bucket_count = ((max_value - min_value) // bucket_size + 1)
buckets = [[] for _ in range(int(bucket_count))]
for i in range(len(my_list)):
buckets[int((my_list[i] - min_value) // bucket_size)].append(my_list[i])