Do counting sort for every digit . Note that instead of passing digit number , exp is passed . exp is 10 ^ i where i is current digit number
for ( $ exp = 1 ; $ m / $ exp > 0 ; $ exp *= 10 ) countSort ( $ arr , $ n , $ exp ) ; }