erez_ez has asked for the wisdom of the Perl Monks concerning the following question:
Again, this is not necessarily the structure of each word. For example, it can be also abc_25_pur5llt3. I already tried using the following code(in various versions) but it works on certain lists(such as the one I showed above) and doesnt on others:a1_1[1] a1_1[2] a1_1[10] a1_2[1] a1_2[2] a1_2[10] a1_10[1] a1_10[2] a1 +_10[10] a2_1[1] a2_1[2] a2_1[10] a2_2[1] a2_2[2] a2_2[10] a2_10[1] a2_10[2] a2 +_10[10] a10_1[1] a10_1[2] a10_1[10] a10_2[1] a10_2[2] a10_2[10] a10_10[1] a10_ +10[2] a10_10[10] b1_1[1] b1_1[2] b1_1[10] b1_2[1] b1_2[2] b1_2[10] b1_10[1] b1_10[2] b1 +_10[10] b2_1[1] b2_1[2] b2_1[10] b2_2[1] b2_2[2] b2_2[10] b2_10[1] b2_10[2] b2 +_10[10] b10_1[1] b10_1[2] b10_1[10] b10_2[1] b10_2[2] b10_2[10] b10_10[1] b10_ +10[2] b10_10[10]
I would accept any code that will make the job done. I just cant make mine to work probably because I cant totally understand it(I got it from one of the Monks). Thank you!my @new_list = sort { ($a =~ /(\w+)(\w+)(\d+)/)[0] cmp ($b =~ /(\w+)(\w+)(\d+)/)[0] || ($a =~ /\[(\d+)/)[0] <=> ($b =~ /\[(\d+)/)[0] } @split_list;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Sort problems
by Corion (Patriarch) on Dec 11, 2008 at 14:49 UTC | |
|
Re: Sort problems
by ccn (Vicar) on Dec 11, 2008 at 14:47 UTC | |
by ikegami (Patriarch) on Dec 11, 2008 at 16:01 UTC | |
by erez_ez (Acolyte) on Dec 11, 2008 at 16:19 UTC | |
by ikegami (Patriarch) on Dec 11, 2008 at 17:20 UTC | |
by erez_ez (Acolyte) on Dec 23, 2008 at 13:39 UTC | |
| |
by erez_ez (Acolyte) on Dec 11, 2008 at 15:51 UTC | |
|
Re: Sort problems
by Herkum (Parson) on Dec 11, 2008 at 14:59 UTC | |
|
Re: Sort problems
by GrandFather (Saint) on Dec 11, 2008 at 22:08 UTC | |
|
Re: Sort problems
by hangon (Deacon) on Dec 12, 2008 at 04:50 UTC |