8 ms·
Radix-exchange sort: sort = (begin, end, bit) -> i = begin j = end mask = 1 << bit while i < j while i < j and !(VA.get(i) & mask)
by mayoff 15y ago
Radix-exchange sort:
sort = (begin, end, bit) ->
i = begin
j = end
mask = 1 << bit
while i < j
while i < j and !(VA.get(i) & mask)
++i
while i < j and (VA.get(j - 1) & mask)
--j
if i < j
VA.swap(i++, --j)
if bit and i > begin
sort(begin, i, bit - 1)
if bit and i < end
sort(i, end, bit - 1)
sort(0, VA.length, 30)
- eridius 15y agoNeat, I've never actually seen a radix sort before. I thought it was a bit clearer to understand what it was doing when I stuck VA.locals.bit = bit at the very top of your sort function.