Skip to content

Instantly share code, notes, and snippets.

@thebopshoobop
Created October 2, 2017 06:33
Show Gist options
  • Save thebopshoobop/7d227ce4dcc0b1a46b3a89927af57dfd to your computer and use it in GitHub Desktop.
Save thebopshoobop/7d227ce4dcc0b1a46b3a89927af57dfd to your computer and use it in GitHub Desktop.
// Start with an unsorted array
[95, 93, 36, 74, 33]
// Place them in the appropriate buckets for the least significant digit
{3: [93, 33], 4: [74], 5: [95], 6: [36]}
// And extract them back into an array
[93, 33, 74, 95, 36]
// Repeat for the next significant digit
{3: [33, 36], 4: [43], 7: [74], 9: [93, 95]}
// And we're Sorted!
[33, 36, 43, 74, 93, 95]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment