Methods by type

min / max / minmax

Full

The least and greatest element — by natural order or a computed key.

.min and .max return the extreme elements; with a block they compare by a computed key. .minmax returns both ends at once as a range.

By a computed key #

Pass a key extractor to compare by something other than the value — here, string length.

say <bb a ccc>.min(*.chars);
say <bb a ccc>.max(*.chars);
Output
a
ccc

a is shortest, ccc longest — the comparison is on .chars, not alphabetical order.

minmax — both ends #

.minmax returns a Range from the least to the greatest element.

say (3, 1, 2).minmax;
Output
1..3

Notes #