Hi,

On 01.10.2016 19:57, mimosinnet wrote:
> I have been searching on how to sort multidimensional arrays. The 
> following code works and sorts the fourth column of the array:
> 
> ---
> #!/usr/bin/env perl6
> # sort multidimensional array 
> 
> my @opposite = (
>       <8976 ABD AB11 6LX NJ >,
>       <8860 PLN AB12 4JS NO >,
>       <8905 DYC AB21 7EQ NJ >,
>       <8964 STN AB39 2NE NO >,
> );
> 
> for @opposite -> $line { say $line; }
> say "-" x 22;
> @opposite = @opposite.sort({@$^a[3]});

For the record, you can simplify this a bit:

@opposite = @opposite.sort(*[3]);


> for @opposite -> $line { say $line; }
> ---
> 
> I have adapted this from: 
> http://www.wellho.net/resources/ex.php?item=p600/mapper
> 
> I wanted to ask about the syntax, buy I have understood it while 
> writing the message ;) :D 

I've had the same experience a few times :-)

Cheers,
Moritz

-- 
Moritz Lenz
https://deploybook.com/ -- https://perlgeek.de/ -- https://perl6.org/

Reply via email to