Logo

Programming-Idioms

History of Idiom 100 > diff from v38 to v39

Edit summary for version 39 by robbat2:
New Perl implementation by user [robbat2]

Version 38

2017-03-06, 21:25:09

Version 39

2017-06-03, 07:50:48

Idiom #100 Sort by a comparator

Sort elements of array-like collection items, using a comparator c.

Idiom #100 Sort by a comparator

Sort elements of array-like collection items, using a comparator c.

Extra Keywords
list
Extra Keywords
list
Code
sub c {
 a <=> $b;
}

my @result = sort c @items;

Comments bubble
Returns a sorted list.
Doc URL
https://perldoc.perl.org/functions/sort.html
Origin
https://perldoc.perl.org/functions/sort.html