Skip to content

Instantly share code, notes, and snippets.

@bdotdub
Created January 9, 2009 18:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bdotdub/45207 to your computer and use it in GitHub Desktop.
Save bdotdub/45207 to your computer and use it in GitHub Desktop.
Comparison between perl and ruby code. Ruby wins in my book
@tuples = sort { $a->[0] <=> $b->[0] } @tuples;
my $dates = map { $_->[0] } @tuples;
my $values = map { $_->[1] } @tuples;
tuples.sort!{ |first, second| first[0] <=> second[0] }
dates = tuples.map{ |tuple| tuple[0] }
values = tuples.map{ |tuple| tuple[1] }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment