'For demo______________________________________________________________________
RADIX_SORT (test())
'_____________________________________________________________________________
length = ALGTH(ARR())
'Function for radix sort
'Find largest element in the Array
max = AMAX(ARR(), length)
'Counting sort is performed based on place, like ones place, tens place and so on.
place = 1
CALL COUNT_SORT
(ARR
(), place
) place = place * 10
SUB COUNT_SORT
(ARR
(), PLACE
)
'Range of the number is 0-9 for each place considered.
'Count number of occurrences in count array
index = ARR(i) \ PLACE
count(idx) = count(idx) + 1
'Change count[i] so that count[i] now contains actual position of this digit in output()
count(i) = count(i) + count(i - 1)
'Build the output array
i = length - 1
index = ARR(i) \ PLACE
oput(c) = oput(c) - 1
count(idx) = count(idx) - 1
i = 0
ARR(i) = oput(i)
'______________________________________________________________________________
x = ARR(i - 1)
y = ARR(i)
tmx = x
tmx = y
AMAX = tmx
'______________________________________________________________________________