Skip to content

Instantly share code, notes, and snippets.

void rsort(uint64_t *a, uint64_t n, uint64_t *b)
{
uint32_t cnt[0x4001]={};
for (size_t i=0;i<n;i++) cnt[(a[i]&0x1fff)+1]++;
for (size_t i=0;i<0x2000;i++) cnt[i+1]+=cnt[i];
for (size_t i=0;i<n;i++) b[cnt[a[i]&0x1fff]++]=a[i];
std::swap(a, b);
for (size_t i=0;i<0x2000;i++) cnt[i]=0;