/* * C Subroutine to Sort Integere Array * Input should be an array of n integers in the range [0,n-1] */ /* Function for bucket sort */ void Bucket_Sort(int array[], int ans[], int n) { int i, j; int count[n]; for (i = 0; i < n; i++) count[i] = 0; for (i = 0; i < n; i++) (count[array[i]])++; for (i = 1 ; i < n; i++) count[i]= count[i]+count[i-1]; for (i = 0; i < n; i++) { ans[count[array[i]]-1] = array[i]; count[array[i]]= count[array[i]]- 1; } } /* End of Bucket_Sort() */