Logo

Programming-Idioms

History of Idiom 100 > diff from v52 to v53

Edit summary for version 53 by jon:
[Perl] missing $

Version 52

2019-09-26, 22:20:53

Version 53

2019-09-28, 02:11:49

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;

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

my @result = sort c @items;

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