Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
+ (void)hexadecimalRadixSort2:(int[])input length:(int)l {
int max = [self findMax:input length:l];
int partiallySorted[l];
int i;
int powerOf16 = 0;
int bin[16];
while ((1 << (powerOf16 << 2)) < max) {
for (int i = 0; i < 16; i++) bin[i] = 0;
for (i = 0; i < l; i++) bin[(input[i] >> (powerOf16 << 2)) & 0x0f]++; // get counts of current digits
for (i = 1; i < 16; i++) bin[i] += bin [i - 1]; // convert counts to array indices
for (i = l - 1; i >= 0; i--) partiallySorted[--bin[(input[i] >> (powerOf16 << 2)) & 0x0f]] = input[i];
for (i = 0; i < l; i++) input[i] = partiallySorted[i];
powerOf16++;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.