Skip to content

Instantly share code, notes, and snippets.

@hakobe
Created September 8, 2008 20:16
Show Gist options
  • Save hakobe/9524 to your computer and use it in GitHub Desktop.
Save hakobe/9524 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
use strict;
use warnings;
sub bucket_sort {
my ($array, $range) = @_;
my @bucket;
push @{ $bucket[$_] ||= [] }, $_ for @$array;
return [ map {@{$bucket[$_]}} grep {$bucket[$_]} (0..$range) ];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment