RE: sort with special order

2009-07-24 Thread Jo for lists and groups
How about this? Jo #!/usr/bin/perl use strict; use warnings; my @list = qw/dog is a there/; my @sortOrder = (3,1,2,0); my @sorted; foreach (@sortOrder) { push(@sorted,$list[$_]); } print @sorted; exit; -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands,

Re: sort with special order

2009-07-24 Thread Steve Bertrand
Jo for lists and groups wrote: How about this? Jo #!/usr/bin/perl use strict; use warnings; my @list = qw/dog is a there/; my @sortOrder = (3,1,2,0); my @sorted; foreach (@sortOrder) { push(@sorted,$list[$_]); } print @sorted; exit; ...or this: #!/usr/bin/perl use strict; use

Re: sort with special order

2009-07-24 Thread Steve Bertrand
Steve Bertrand wrote: Jo for lists and groups wrote: How about this? Jo #!/usr/bin/perl use strict; use warnings; my @list = qw/dog is a there/; my @sortOrder = (3,1,2,0); my @sorted; foreach (@sortOrder) { push(@sorted,$list[$_]); } print @sorted; exit; ...or this:

Re: sort with special order

2009-07-24 Thread Chas. Owens
On Fri, Jul 24, 2009 at 11:01, Jo for lists and groupsourli...@rogers.com wrote: How about this? Jo #!/usr/bin/perl use strict; use warnings; my @list = qw/dog is a there/; my @sortOrder = (3,1,2,0); my @sorted; foreach (@sortOrder) { push(@sorted,$list[$_]); } print @sorted; exit;

sort with special order

2009-07-23 Thread sys adm
Hi, When I got a word list, I want it to be sorted with special order. for example, I got this array: (dog,is,a,there); I want the sorted result is: (there,is,a,dog); How to code it? Thank you. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail:

Re: sort with special order

2009-07-23 Thread Chas. Owens
On Fri, Jul 24, 2009 at 00:14, sys admsys...@computermail.net wrote: Hi, When I got a word list, I want it to be sorted with special order. for example, I got this array: (dog,is,a,there); I want the sorted result is: (there,is,a,dog); How to code it? Thank you. snip You need to some

sort with special order

2005-10-03 Thread JupiterHost.Net
Howdy List :) I have a list of strings that start with an uppercase B, Q, or Z I need to sort them so they are in order of Q, B , then Z my @sample_strings = qw(Bang Quiet Zing Zop Quid Boo); I need them to be sorted as: Quid Quiet Bang Boo Zing Zop I'd like to sort() them but can't

Re: sort with special order

2005-10-03 Thread Xavier Noria
On Oct 3, 2005, at 17:35, JupiterHost.Net wrote: I need to sort them so they are in order of Q, B , then Z The real array will have between 1 to 100 items, just FYI They all go in ASCII relative order except B - Q, thus a way to get it is to handle that special case and delegate to cmp

Re: sort with special order

2005-10-03 Thread Jeff 'japhy' Pinyan
On Oct 3, JupiterHost.Net said: I have a list of strings that start with an uppercase B, Q, or Z I need to sort them so they are in order of Q, B , then Z Any ideas or input on how to efficiently do that with sort() or even map() is most appreciated :) perldoc -f sort|-f map didn't appear to

Re: [SPAM DETECT] Re: sort with special order

2005-10-03 Thread Xavier Noria
On Oct 3, 2005, at 18:16, Jeff 'japhy' Pinyan wrote: On Oct 3, JupiterHost.Net said: I have a list of strings that start with an uppercase B, Q, or Z I need to sort them so they are in order of Q, B , then Z Any ideas or input on how to efficiently do that with sort() or even map() is

Re: sort with special order

2005-10-03 Thread JupiterHost.Net
On Oct 3, JupiterHost.Net said: I have a list of strings that start with an uppercase B, Q, or Z I need to sort them so they are in order of Q, B , then Z Any ideas or input on how to efficiently do that with sort() or even map() is most appreciated :) perldoc -f sort|-f map didn't appear to

Re: [SPAM DETECT] Re: sort with special order

2005-10-03 Thread Jeff 'japhy' Pinyan
On Oct 3, Xavier Noria said: On Oct 3, 2005, at 18:16, Jeff 'japhy' Pinyan wrote: my @sorted = map { tr/123/QBZ/; $_ } sort map { tr/QBZ/123/; $_ } @data; There's a potential gotcha there: since all Qs and Bs are being swapped lexicographic order after the first character

RE: sort with special order

2005-10-03 Thread Bakken, Luke
JupiterHost.Net wrote: On Oct 3, JupiterHost.Net said: I have a list of strings that start with an uppercase B, Q, or Z I need to sort them so they are in order of Q, B , then Z Any ideas or input on how to efficiently do that with sort() or even map() is most appreciated :) perldoc -f

Re: sort with special order

2005-10-03 Thread Jay Savage
On 10/3/05, Bakken, Luke [EMAIL PROTECTED] wrote: JupiterHost.Net wrote: On Oct 3, JupiterHost.Net said: I have a list of strings that start with an uppercase B, Q, or Z I need to sort them so they are in order of Q, B , then Z Any ideas or input on how to efficiently do that with

Re: sort with special order

2005-10-03 Thread John W. Krahn
Bakken, Luke wrote: JupiterHost.Net wrote: On Oct 3, JupiterHost.Net said: I have a list of strings that start with an uppercase B, Q, or Z I need to sort them so they are in order of Q, B , then Z Any ideas or input on how to efficiently do that with sort() or even map() is most appreciated

Re: sort with special order

2005-10-03 Thread Jeff 'japhy' Pinyan
[sorry, PINE has become very confused about who said what] On Oct 3, Jay Savage said: On 10/3/05, Bakken, Luke [EMAIL PROTECTED] wrote: JupiterHost.Net wrote: On Oct 3, JupiterHost.Net said: I have a list of strings that start with an uppercase B, Q, or Z I need to sort them so they are