Skip to content

Instantly share code, notes, and snippets.

@hiratara
Created March 25, 2016 07: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 hiratara/c56113377280f0b7bfd4 to your computer and use it in GitHub Desktop.
Save hiratara/c56113377280f0b7bfd4 to your computer and use it in GitHub Desktop.
A scope of `sort` pragma
use strict;
use warnings;
use Test::More;
use sort '_quicksort';
sub test_sort () {
my @sorted = sort { $a->[1] <=> $b->[1] } map { [$_, $_ % 2] } 1 .. 100;
is_deeply \@sorted, [(map { [$_ * 2, 0] } 1 .. 50), (map { [$_ * 2 - 1, 1] } 1 .. 50)];
}
{
use sort 'stable';
test_sort;
}
done_testing;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment