Skip to content

Instantly share code, notes, and snippets.

@posaunehm
Created January 26, 2012 04:52
Show Gist options
  • Save posaunehm/1681072 to your computer and use it in GitHub Desktop.
Save posaunehm/1681072 to your computer and use it in GitHub Desktop.
BucketSort
public static IEnumerable<int> BucketSort(IEnumerable<int> input)
{
int[] bucket = new int[input.Max() + 1];
foreach(var ele in input)
{
bucket[ele]++;
}
return bucket.SelectMany((i, ele) => Enumerable.Range(0, i).Select(_ => ele));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment