Sort stability

The sort built-in (available as sub and method) is stable.

Short demonstration for sorting only on the second item of each array:

use v6;
my @cities =
    ['UK', 'London'],
    ['US', 'New York'],
    ['US', 'Birmingham'],
    ['UK', 'Birmingham'],
    ;

.say for @cities.sort: { .[1] };

Last updated