aboutsummaryrefslogtreecommitdiff
path: root/challenge-040/arne-sommer/perl6/array-partialsort
blob: 039420588eb2e607411d7546841d053b76320223 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#! /usr/bin/env raku

sub MAIN (:$verbose, :$list = "10 4 1 8 12 3", :$sort = "0 2 5")
{
  my @array   = $list.words>>.Numeric;
  my @indeces = $sort.words;

  if $verbose
  {
    say ":A: @array[]";
    say ":I: @indeces[]";
    say ":O: @array[@indeces]";
    say ":R: { @array[@indeces].=sort }";
  }
  else
  {
    @array[@indeces].=sort;
  }

  say @array;
}