- Original Message -
From: "Chris Wagner" <[EMAIL PROTECTED]>
To:
Sent: Sunday, December 18, 2005 9:26 AM
Subject: Re: Sort question
> I'm a little amazed this works but it does. :)
>
> @nums = qw(55_20051202 56_20051203 57_20051204 101_20051205 59_2005
I'm a little amazed this works but it does. :)
@nums = qw(55_20051202 56_20051203 57_20051204 101_20051205 59_20051206
10_20051207 61_20051208 62_20051208 63_20051208 64_20051209 65_20051209
66_20051210 67_20051211 68_20051212 69_20051213 70_20051214);
print join "\n", (map {join "_", @{$_}} (sort
- Original Message -
From: "Wong, Danny H." <[EMAIL PROTECTED]>
To:
Sent: Saturday, December 17, 2005 7:04 AM
Subject: Sort question
> Hi Guys,
> I have an array of values. How can I sort these values that has
> a non numeric character [ _ ] in it? What I did was parse the numbers
> be
I have an array of values. How can I sort these values that has
a non numeric character [ _ ] in it? What I did was parse the numbers
before the "_" character and then perform a number short on those
value, but there must be an easier way? Any help is greatly
appreciated.
55_20051202
On 12/16/05, Wong, Danny H. <[EMAIL PROTECTED]> wrote:> Hi Guys,> I
have an array of values. How can I sort these values that has> a non numeric
character [ _ ] in it? What I did was parse the numbers> before the "_"
character and then perform a number short on those value,> but there mu
[EMAIL PROTECTED] wrote:
> Hi Guys,
> I have an array of values. How can I sort these values that has
> a non numeric character [ _ ] in it? What I did was parse the numbers
> before the "_" character and then perform a number short on those
> value, but there must be an easier way? Any help
"$Bill Luebkert" wrote:
> Michael Meltzer wrote:
>
> > The following strings I have in an array:
> >
> > xyz
> > abcd
> > ZABC
> >
> > if I do @sorted = sort(@unsorted) I get
> >
> > ZABC
> > abcd
> > xyz
> >
> > I would like to sort this strings alphabetical ignoring capitalisation but
> > whith
> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On
> Behalf Of Michael Meltzer
> Sent: Wednesday, December 15, 2004 2:44 PM
> To: Perl-Win32-Users
> Subject: sort question
>
> The following strings I have in an array:
>
> xyz
>
Michael Meltzer wrote:
> The following strings I have in an array:
>
> xyz
> abcd
> ZABC
>
> if I do @sorted = sort(@unsorted) I get
>
> ZABC
> abcd
> xyz
>
> I would like to sort this strings alphabetical ignoring capitalisation but
> whithout changing the output format.
> I want to get this
Try:
@sorted = sort {uc $a cmp uc $b) (@unsorted);
This compares (cmp) the upper case of the two values (uc) without modifying
them.
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Michael Meltzer
Sent: Wednesday, December 15, 2004 1:44 PM
To: Perl-Win32-U
Thanks for the help with sort. Anyone aware of a module to connect to a
remote host over the old DECnet LAT protocol? cpan yielded no matches but I
thought maybe there was something out there...
> -Original Message-
> From: Peter Eisengrein [mailto:[EMAIL PROTECTED]]
> Sent: Thursday,
> -Original Message-
> Behalf Of Peter Eisengrein
>
> This is probably really easy but I couldn't find it in the docs. I have a
> multicolumn list that has between 5000-6000 lines and looks something like
> this:
>
> 47 3950 0 Y Y N N OOSM
Just parse each line ($a and $b) within your sort subroutine, e.g.:
#!/usr/bin/perl
sub sorter {
my (@a,@b);
@a = split(/\s+/,$a);
@b = split(/\s+/,$b);
@a[1] <=> @b[1];
}
@lines = <>;
print sort sorter @lines;
-Jonathan
At 11:32 AM 1/3/2002, Peter Eisengrein wrote:
>This is probab
You can write your own procedure to sort data however you want. perldoc -f sort
should give you a start. Supposing that you have this stored as an array of
references to an array, you could do something like
sort { $::a->[1] cmp $::b->[1] } @data
which would sort on the second column.
HTH,
Ri
14 matches
Mail list logo