Sort stability: Difference between revisions
→{{header|Perl 6}}: started section
m (→{{header|J}}) |
(→{{header|Perl 6}}: started section) |
||
Line 145:
The stability of Perl's in-built [http://perldoc.perl.org/functions/sort.html sort] function is version-dependent. If you want to guarantee a stable sort from it, you should use the following [http://perldoc.perl.org/sort.html sort pragma]:
<lang perl>use sort 'stable';</lang>
=={{header|Perl 6}}==
The [http://perlcabal.org/syn/S32/Containers.html#sort sort] built-in (available as sub and method) is stable.
Short demonstration for sorting only on the first item of each array:
<lang>
use v6;
my @cities =
['UK', 'London'],
['US', 'New York'],
['US', 'Birmingham'],
['UK', 'Birmingham'],
;
.say for @cities.sort: { .[0] };
</lang>
=={{header|PicoLisp}}==
|