Created
March 25, 2016 07:15
-
-
Save hiratara/c56113377280f0b7bfd4 to your computer and use it in GitHub Desktop.
A scope of `sort` pragma
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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