onlyIDleft has asked for the wisdom of the Perl Monks concerning the following question:
@a1 = qw (ID1 len1 dom1 domlen1 seq1); @a2 = qw (ID2 len2 dom2 domlen2 seq2); @a3 = qw (ID3 len3 dom3 domlen3 seq3); $line1 = /@a1; $line2 = /@a2; $line3 = /@a3; @array =qw ($line1 $line2 $line3); # an array of array references.
I want to first sort @array by element 1 of @a1, @a2, @a3 i.e. $ID , then by element 2 - $dom, then by element 3 - $domlen, by element 4 - $seq (which would be an alphabetical sort) and finally by element [0] - $ID (another alphabetical sort).
After this sort, I want to extract the 1st element - "ID" from 1st de-referenced array, in @sorted_array
I tried something on the lines of the suggestion at : http://www.perlmonks.org/?node_id=674374 by jettero, but get an error message - I suppose because what I am trying is to sort by elements in the deferenced array of arrays- which is not what the post here is talking about, right?
Thank you in advance!
PS. Sorry about the long post title
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: sorting array of array references with multiple dereferenced array elements
by jonadab (Parson) on Sep 23, 2014 at 12:51 UTC | |
by LanX (Saint) on Sep 23, 2014 at 13:16 UTC | |
by onlyIDleft (Scribe) on Sep 23, 2014 at 13:48 UTC | |
by onlyIDleft (Scribe) on Sep 23, 2014 at 15:04 UTC | |
|
Re: sorting array of array references with multiple dereferenced array elements
by LanX (Saint) on Sep 23, 2014 at 12:12 UTC | |
|
Re: sorting array of array references with multiple dereferenced array elements
by andal (Hermit) on Sep 23, 2014 at 13:33 UTC |