Lines Matching refs:sort

13     sort { for ($_ = 0;; $_++) {} } @a;
14 sort { while(1) {} } @a;
15 sort { while(1) { last; } } @a;
16 sort { while(0) { last; } } @a;
41 $x = join('', sort @harry);
46 $x = join('', sort( Backwards @harry));
51 $x = join('', sort( Backwards_stacked @harry));
56 $x = join('', sort @george, 'to', @harry);
84 @b = sort {$a <=> $b;} @a;
88 $x = join('', sort $sub @harry);
94 $x = join('', sort $sub @harry);
101 @b = sort (4,1,3,2);
105 @b = sort grep { $_ } (4,1,3,2);
109 @b = sort map { $_ } (4,1,3,2);
113 @b = sort reverse (4,1,3,2);
117 # redefining sort sub inside the sort sub should fail
119 eval { @b = sort twoface 4,1,3,2 };
120 print ($@ =~ /redefine active sort/ ? "ok 17\n" : "not ok 17\n");
122 # redefining sort subs outside the sort should not fail
126 eval { @b = sort twoface 4,1,3,2 };
133 eval { @b = sort twoface 4,1 };
134 print ($@ =~ /redefine active sort/ ? "ok 20\n" : "not ok 20\n");
140 die($@ =~ /redefine active sort/ ? "ok 21\n" : "not ok 21\n");
144 eval { @b = sort twoface 4,1 };
148 my @result = sort main'Backwards 'one', 'two';
153 # "sort 'one', 'two'" should not try to parse "'one" as a sort sub
154 my @result = sort 'one', 'two';
163 @b = sort $sortsub 4,1,3,2;
165 @b = sort $sortglob 4,1,3,2;
167 @b = sort $sortname 4,1,3,2;
169 @b = sort $sortglobr 4,1,3,2;
178 @b = sort $sortsub 4,1,3,2;
180 @b = sort $sortglob 4,1,3,2;
182 @b = sort $sortname 4,1,3,2;
184 @b = sort $sortglobr 4,1,3,2;
193 @b = sort $sortsub 4,1,3,2;
195 @b = sort $sortglob 4,1,3,2;
197 @b = sort $sortname 4,1,3,2;
199 @b = sort $sortglobr 4,1,3,2;
208 @b = sort $sortsub 4,1,3,2;
210 @b = sort $sortglob 4,1,3,2;
212 @b = sort $sortname 4,1,3,2;
214 @b = sort $sortglobr 4,1,3,2;
218 ## exercise sort builtins... ($a <=> $b already tested)
220 @b = sort {
226 $x = join('', sort { $a cmp $b } @harry);
230 $x = join('', sort { $b cmp $a } @harry);
236 @b = sort { $a <=> $b } @a;
239 @b = sort { $b <=> $a } @a;
242 $x = join('', sort { $a cmp $b } @harry);
246 $x = join('', sort { $b cmp $a } @harry);
254 $x = join('', sort { $a <=> $b } 3, 1, 2);
260 @b = sort { $b <=> $a } @a;
264 @b = sort main::Backwards_stacked @a;
268 # check if context for sort arguments is handled right
279 sub cxt_one { sort $m test_if_list() }
281 sub cxt_two { sort { $a <=> $b } test_if_list() }
283 sub cxt_three { sort &test_if_list() }
294 sub cxt_four { sort $m 1,2 }
296 sub cxt_five { sort { test_if_scalar($a,$b); } 1,2 }
298 sub cxt_six { sort test_if_scalar 1,2 }
305 sub reenter { my @force = sort compare qw/a b/ }
309 @b = sort {
322 @a = sort(routine(1));
335 # check for in-place optimisation of @a = sort @a
339 @g = (3,2,1); $r1 = \$g[2]; @g = sort @g; $r2 = \$g[0];
340 ok "$r1-@g", "$r2-1 2 3", "inplace sort of global";
342 @a = qw(b a c); $r1 = \$a[1]; @a = sort @a; $r2 = \$a[0];
343 ok "$r1-@a", "$r2-a b c", "inplace sort of lexical";
345 @g = (2,3,1); $r1 = \$g[1]; @g = sort { $b <=> $a } @g; $r2 = \$g[0];
346 ok "$r1-@g", "$r2-3 2 1", "inplace reversed sort of global";
349 $r1 = \$g[1]; @g = sort { $a<$b?1:$a>$b?-1:0 } @g; $r2 = \$g[0];
350 ok "$r1-@g", "$r2-3 2 1", "inplace custom sort of global";
353 @a = qw(b c a); $r1 = \$a[1]; @a = sort mysort @a; $r2 = \$a[0];
354 ok "$r1-@a", "$r2-c b a", "inplace sort with function of lexical";
360 @t = qw(b c a); @t = sort @t;
361 ok "@t", "a b c", "inplace sort of tied array";
363 @t = qw(b c a); @t = sort mysort @t;
364 ok "@t", "c b a", "inplace sort of tied array with function";
366 # [perl #29790] don't optimise @a = ('a', sort @a) !
368 @g = (3,2,1); @g = ('0', sort @g);
369 ok "@g", "0 1 2 3", "un-inplace sort of global";
370 @g = (3,2,1); @g = (sort(@g),'4');
371 ok "@g", "1 2 3 4", "un-inplace sort of global 2";
373 @a = qw(b a c); @a = ('x', sort @a);
374 ok "@a", "x a b c", "un-inplace sort of lexical";
375 @a = qw(b a c); @a = ((sort @a), 'x');
376 ok "@a", "a b c x", "un-inplace sort of lexical 2";
378 @g = (2,3,1); @g = ('0', sort { $b <=> $a } @g);
379 ok "@g", "0 3 2 1", "un-inplace reversed sort of global";
380 @g = (2,3,1); @g = ((sort { $b <=> $a } @g),'4');
381 ok "@g", "3 2 1 4", "un-inplace reversed sort of global 2";
383 @g = (2,3,1); @g = ('0', sort { $a<$b?1:$a>$b?-1:0 } @g);
384 ok "@g", "0 3 2 1", "un-inplace custom sort of global";
385 @g = (2,3,1); @g = ((sort { $a<$b?1:$a>$b?-1:0 } @g),'4');
386 ok "@g", "3 2 1 4", "un-inplace custom sort of global 2";
388 @a = qw(b c a); @a = ('x', sort mysort @a);
389 ok "@a", "x c b a", "un-inplace sort with function of lexical";
390 @a = qw(b c a); @a = ((sort mysort @a),'x');
391 ok "@a", "c b a x", "un-inplace sort with function of lexical 2";