On Fri, 17 Jun 2016 14:33:12 -0700
Kenneth Wolcott wrote:
> Hi;
>
> I'm having trouble understanding the built-in Perl sort with regards
> to mixed numbers and strings
>
> I'm looking at http://perldoc.perl.org/functions/sort.html
>
> I have a
compare" routine uses $a and $b which are "special" to perl
>> sort routines.
>> Also the compare routine is written for obviousness rather than for brevity
>> or elegance.
>>
>> The return from compare illustrates Shalomi Fish's point about usi
Hi Chris,
On Mon, 20 Jun 2016 11:28:57 -0600
Chris Fedde wrote:
> Kenneth,
>
> Below the cut is my example implementation as I understand your
> requirements.
> Note that the "compare" routine uses $a and $b which are "special" to perl
> sort routines.
>
Kenneth,
Below the cut is my example implementation as I understand your
requirements.
Note that the "compare" routine uses $a and $b which are "special" to perl
sort routines.
Also the compare routine is written for obviousness rather than for brevity
or elegance.
The
Hi Kenneth,
On Fri, 17 Jun 2016 14:41:41 -0700
Kenneth Wolcott wrote:
> On Fri, Jun 17, 2016 at 2:33 PM, Kenneth Wolcott
> wrote:
> > Hi;
> >
> > I'm having trouble understanding the built-in Perl sort with regards
> > to mixed numbers and st
In this very particular case you should consider turning off the warning,
maybe limiting it to the block.
On Jun 17, 2016 5:42 PM, "Kenneth Wolcott" wrote:
> On Fri, Jun 17, 2016 at 2:33 PM, Kenneth Wolcott
> wrote:
> > Hi;
> >
> > I'm having trouble un
If you want to sort your data numerically, then the data must look like a
number. Your data is mixed numerical and alpha data, hence the error message.
You first need to extract the numerical parts of your data records and compare
just those parts.
The first step would be to write a sort
On Fri, Jun 17, 2016 at 2:33 PM, Kenneth Wolcott
wrote:
> Hi;
>
> I'm having trouble understanding the built-in Perl sort with regards
> to mixed numbers and strings
>
> I'm looking at http://perldoc.perl.org/functions/sort.html
>
> I have an array that I w
Hi;
I'm having trouble understanding the built-in Perl sort with regards
to mixed numbers and strings
I'm looking at http://perldoc.perl.org/functions/sort.html
I have an array that I want to have sorted numerically and descending.
The array is composed of elements that loo
Probably you have "use warnings" turned on. You can disable the warning for
numeric comparison with "no warnings 'numeric';"
perl -E 'use warnings; no warnings "numeric"; my @a =
("12\thi","37\tb","123\tc","187\ta&quo
On Tue, 8 Mar 2016 13:29:40 -0800
Kenneth Wolcott wrote:
> How do I call the built-in Perl sort function on an array of strings
> where the string is composed of one or more digits, followed by a tab
> which is followed by a string and I want the results to be sorted in
> reverse n
> Hi;
>
> How do I call the built-in Perl sort function on an array of strings
> where the string is composed of one or more digits, followed by a tab
> which is followed by a string and I want the results to be sorted in
> reverse numeric order?
>
> I looked at http
Hi;
How do I call the built-in Perl sort function on an array of strings
where the string is composed of one or more digits, followed by a tab
which is followed by a string and I want the results to be sorted in
reverse numeric order?
I looked at http://perldoc.perl.org/functions/sort.html
u can see in my code there is no hard coded value.
You can modify the regular expression used to extract the sort values depending
upon the circumstances under which your function will be used. I was just
giving an example of how to combine all of the individual steps into one
command. I based the
:MO=RXOTRX-473-5,SC=0,DCP1=223,SIG=SCCONC,DCP2=224&&231,TEI=5;
> > RXMOI:MO=RXOTRX-473-1,SC=0,DCP1=187,SIG=SCCONC,DCP2=188&&195,TEI=1;
> ...
>
> > This file is from a testing environment. But in production environment
> this file can be more than 500 lines. So m
Am 24.03.2015 um 14:03 schrieb Shlomi Fish:
> This can be more idiomatically written as:
>
> $a->[1] <=> $b->[1] or $a->[2] <=> $b->[2]
I agree, a
sort {
$a->[0] <=> $b->[0] or
$a->[1] <=> $b->[1] or
$a->[2] <
-473-1,SC=0,DCP1=187,SIG=SCCONC,DCP2=188&&195,TEI=1;
...
> This file is from a testing environment. But in production environment this
> file can be more than 500 lines. So my goal is to sort the file based on the
> bold numbers and create a new file.
> This is required for da
Hi Simon,
thanks for helping Anirban, but I have a small comment about your code:
On Tue, 24 Mar 2015 13:11:56 +0100
Simon Reinhardt wrote:
> Hi Anirban,
>
> first we have to be clear how you want to sort the lines.
> Does 10-1 sort before 1-11 ?
> Do you want numeric (use <
Hi Anirban,
first we have to be clear how you want to sort the lines.
Does 10-1 sort before 1-11 ?
Do you want numeric (use <=>) or alphabetic (use cmp) order?
> while (my $line = <$RFH>) {
> chomp($line);
> if ($line =~ m/.*?\-(\d+)\-(\d+).*/) {
>
>) {
chomp;
my($val) = split ',', $_; #split the data using comma
my($key, $value) = split '=', $val; #split the values using equal sign
(=)
$value =~ /.*?-([\d\-]+)$/; #extract the numbers following the pattern
(-DIGIT-DIGIT)
$data{$1} = $_;
}
#sort in a
lit '=', $val; #split the values using equal sign
(=)
$value =~ /.*?-([\d\-]+)$/; #extract the numbers following the pattern
(-DIGIT-DIGIT)
push @data, $1;
}
#sort in ascending order
@data = sort {$a cmp $b} @data;
print join "\n", @data;
[/code]
[data.txt]
RXMOI:MO=RXOTR
line);
if ($line =~ m/.*?\-(\d+)\-(\d+).*/) {
$sequence_no = "$1$2";
# print "$sequence_no-- $line\n";
$file_content_hash{$sequence_no}="$line";
}
}
for my $key ( sort {$a<=>$b} keys %file_conte
O=RXOTRX-*460-1*,SC=0,DCP1=187,SIG=SCCONC,DCP2=188&&195,TEI=1;
RXMOI:MO=RXOTRX-*460-0*,SC=0,DCP1=178,SIG=SCCONC,DCP2=179&&186,TEI=0;
This file is from a testing environment. But in production environment this
file can be more than 500 lines. So my goal is to sort the file based
On 2014-03-26 12:36, shawn wilson wrote:
return
sort {
return $pre->{$a} <=> $pre->{$b}
if $pre->{$a} && $pre->{$b};
return -1 if $pre->{$a};
return +1 if $pre->{$b};
return $a cmp $b;
} @$data;
}
Benchmark-a
Thanks guys:
# Preceed sort with possible presorted values from an array.
sub _sortpre
{
my ($self, $data, $prevals) = @_;
my $i = 1;
my $pre = (ref($prevals) eq 'ARRAY' and scalar(@$prevals) ?
{map {$_ => $i++} @$prevals} : {}
);
return
sort {
return $pre-&
1, third => 1);
And then the output becomes:
Sorted: first, second, third, bar, baz, foo
Which isn't correct.
I humbly beg to differ. Your specification was to sort ‘first’, ‘second’, or
‘third’ before other keys, and the solution I provided does exactly that,
sorting ‘first’, ‘secon
=> 1);
>
> And then the output becomes:
> Sorted: first, second, third, bar, baz, foo
>
> Which isn't correct.
I humbly beg to differ. Your specification was to sort ‘first’, ‘second’, or
‘third’ before other keys, and the solution I provided does exactly that,
sorting ‘first’, ‘s
On Mar 25, 2014, at 6:55 AM, shawn wilson wrote:
> i want to sort an array for certain key words first and then alphabetically.
>
> my @foo = qw/foo bar baz first second third/;
>
> foreach my $i (sort {$a cmp $b} @foo) {
> print "$i\n";
> }
>
> How do
h isn't correct.
On Tue, Mar 25, 2014 at 10:45 AM, Shawn H Corey wrote:
> On Tue, 25 Mar 2014 09:55:25 -0400
> shawn wilson wrote:
>
>> i want to sort an array for certain key words first and then
>> alphabetically.
>>
>> my @foo = qw/foo bar baz f
On Tue, 25 Mar 2014 09:55:25 -0400
shawn wilson wrote:
> i want to sort an array for certain key words first and then
> alphabetically.
>
> my @foo = qw/foo bar baz first second third/;
>
> foreach my $i (sort {$a cmp $b} @foo) {
> print "$i\n";
> }
>
&
Hi Shawn,
On Tue, 25 Mar 2014 09:55:25 -0400
shawn wilson wrote:
> i want to sort an array for certain key words first and then alphabetically.
>
> my @foo = qw/foo bar baz first second third/;
>
> foreach my $i (sort {$a cmp $b} @foo) {
> print "$i\n";
&
i want to sort an array for certain key words first and then alphabetically.
my @foo = qw/foo bar baz first second third/;
foreach my $i (sort {$a cmp $b} @foo) {
print "$i\n";
}
How do I make 'first', 'second', and 'third' come before the rest?
(I
iginal program had {} around the inner elements, not (), which made it an
array of hash references.
> print values($_) for sort my_sort @AoH; sub my_sort {
> values($a)<=>values($b)}
> '
> code
> end
one element.
and i modify this to below
code
begin---
perl -e '
@AoH = (
(
rsh => "0.4",
),
(
telnet=> "0.022",
),
(
ssh => "0.3&qu
Hi xiyoulaoyuanjia,
On Thu, 5 Jul 2012 22:53:03 +0800
xiyoulaoyuanjia wrote:
> hi:
>
> i want sort my array .but the result is not right. i did not know why ?
>
> ---begin
> code--
>
hi:
i want sort my array .but the result is not right. i did not know why ?
---begin
code--
perl -e '
@AoH = (
{
rsh => "0.4",
},
{
telnet=> "0.022",
On Tue, Jul 3, 2012 at 6:44 AM, Chris Stinemetz
wrote:
> On Tue, Jul 3, 2012 at 5:11 AM, xiyoulaoyuanjia
> wrote:
>> hi Rob 。 i do not know what the 'for' meaning inprint $_->[0], "\n" for
>> sort { $b->[1] <=> $a->[1] } @RNC;
>&g
On Tue, Jul 3, 2012 at 5:11 AM, xiyoulaoyuanjia
wrote:
> hi Rob 。 i do not know what the 'for' meaning inprint $_->[0], "\n" for
> sort { $b->[1] <=> $a->[1] } @RNC;
> can you give me mush information about this use 。
> 3ks !
>
I belie
>
> I believe you want the output lines formatted as they are but sorted in
> descending order of the ec_count value, is that right?
>
> I suggest that, instead of printing the data straight from the hash you
> store the lines in an array and sort it before displaying the informa
On 02/07/2012 17:42, Chris Stinemetz wrote:
I have a 3 deminsional hash that I would like to sort on the value in
descending order. I can't quite seem to figure it out
The portion of the program I can't get figured out:
## body
foreach my $frameNo ( keys %RNC ) {
foreach my $ec ( k
On Mon, 2 Jul 2012 11:42:44 -0500
Chris Stinemetz wrote:
> I have a 3 deminsional hash that I would like to sort on the value in
> descending order. I can't quite seem to figure it out
>
> The portion of the program I can't get figured out:
> ## body
> for
I have a 3 deminsional hash that I would like to sort on the value in
descending order. I can't quite seem to figure it out
The portion of the program I can't get figured out:
## body
foreach my $frameNo ( keys %RNC ) {
foreach my $ec ( keys %{$RNC{$frameNo}} ) {
my $ec_co
On 04/16/2012 01:58 AM, Shekar wrote:
if( exists $hash_val{$dom} ) {
my $val=$hash_val{$dom};
$val++;
$hash_val{$dom}=$val;
} else {
$hash_val{$dom}=1;
}
all that code can be replaced with this one line:
$hash_val{$dom}++ ;
pe
split / /,$text;
@sort = ($arr1[3],$arr1[4]);
say "$sort[0] => $sort[1]";
}
result
test:dom1 => CRIT
test:dom2 => CRIT
work:dom1 => CRIT
test:dom1 => CRIT
test:dom2 => CRIT
work:dom1 => CRIT
But, I need count of CRIT.
I try
$hash{$_}++ for
Thanks Uri, and Ruud for lightening up :)
Cheers,
Shekar
On Mon, Apr 16, 2012 at 12:25 PM, Dr.Ruud wrote:
> On 2012-04-16 07:58, Shekar wrote:
>
> next if (/^\s$/);
>>
>
> You probably meant:
>
> next if /^\s*$/; # skip blank lines
>
> --
> Ruud
>
>
> --
> To unsubscribe, e-mail: begin
On 2012-04-16 07:58, Shekar wrote:
next if (/^\s$/);
You probably meant:
next if /^\s*$/; # skip blank lines
--
Ruud
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/
On 04/16/2012 01:58 AM, Shekar wrote:
if( exists $hash_val{$dom} ) {
my $val=$hash_val{$dom};
$val++;
$hash_val{$dom}=$val;
} else {
$hash_val{$dom}=1;
}
all that code can be replaced with this one line:
$hash_val{$dom}++ ;
pe
rk:dom1 - count of CRIT(6)
>
>
> File in .gz format
>
> my code
>
> #!/usr/bin/perl
>
> use strict;
> use warnings;
> use diagnostics;
> use 5.010;
>
> use IO::Compress::Gzip;
> use IO::Uncompress::Gunzip;
>
> my $file = "log.gz";
'strict' enabled your program would have ended here because of the
@arr variable.
At this point @arr will only contain lines that have the pattern 'work'
in them.
foreach my $text (@arr) {
@arr1 = split / /,$text;
@sort = ($arr1[3],$arr1[4]);
With
ip>;
foreach my $text (@arr) {
@arr1 = split / /,$text;
@sort = ($arr1[3],$arr1[4]);
say "$sort[0] => $sort[1]";
$count{$sort[0]}{$sort[1]} ++;
}
for my $k1 ( keys %count ){
for my $k2 ( keys %{ $count{$k1} }){
print "$k1
warnings;
use diagnostics;
use 5.010;
use IO::Compress::Gzip;
use IO::Uncompress::Gunzip;
my $file = "log.gz";
my $ungzip = new IO::Uncompress::Gunzip($file);
@arr = grep /work/, <$ungzip>;
foreach my $text (@arr) {
@arr1 = split / /,$text;
@sort = ($arr1[3],$arr1[
On Sat, Oct 15, 2011 at 03:45, Lemon wrote:
> Many thanks to Shlomi and Paul,
>
>
> I need to read sort manual and map manual.
>
yes, that's a good place to start.
but, just because i like being different and because i really enjoy
the power of this simple little modul
Many thanks to Shlomi and Paul,
Shlomi gave the solution for @array[@a,@b] (@a=(1, 7, 54, 2), @b(2, 89,
78, 33) ), for my case two array may be esay to deal with.
I need to read sort manual and map manual.
Meng Ni
On Fri, Oct 14, 2011 at 11:16 PM, Paul Johnson wrote:
> On Thu, Oct
On Thu, Oct 13, 2011 at 02:39:52AM -0700, Lemon wrote:
> Dear all,
>
> I want to sort data set like this
>
> (@a, @b)
> 1,21,2
> 7,89=> 2,33
> 54,78
On Fri, Oct 14, 2011 at 4:32 PM, Shlomi Fish wrote:
> On Thu, 13 Oct 2011 02:39:52 -0700 (PDT)
> Lemon wrote:
>
> > Dear all,
> >
> > I want to sort data set like this
> >
> > (@a, @b)
> > 1,21,2
> &g
On Thu, 13 Oct 2011 02:39:52 -0700 (PDT)
Lemon wrote:
> Dear all,
>
> I want to sort data set like this
>
> (@a, @b)
> 1,21,2
> 7,89=> 2,33
> 54,78
Dear all,
I want to sort data set like this
(@a, @b)
1,21,2
7,89=> 2,33
54,787,89
2,33 54,78
I know that linux command sort can
I'm wondering (as i faced this a week ago or so), how much memory does
this take up (over the original data) ? and whether it's worth it (ie,
does this save me anything over a sort)? and is there a better way to
do this (if it doesn't take up much more memory and does save over a
s
thanks rob. it worked
From: Rob Dixon
To: beginners@perl.org
Cc: Irfan Sayed
Sent: Thursday, June 23, 2011 3:37 PM
Subject: Re: sort hash
On 23/06/2011 10:36, Irfan Sayed wrote:
> Hi,
>
> i need to sort hash in descending order.
> but the issue
On 2011-06-23 11:36, Irfan Sayed wrote:
[I need to sort a hash, but my keys are integers]
Realize that all hash keys are strings.
sort { $hash_fin{$b} <=> $hash_fin{$a} } keys %hash_fin
You were almost there:
sort { $b <=> $a } keys %hash_fin
The <=> operator is
On 23/06/2011 10:36, Irfan Sayed wrote:
> Hi,
>
> i need to sort hash in descending order.
> but the issue is , in hash, i have key as integer value and the value
> associated with that key is string
>
> so when i do sort it does not really sort the hash on the key
Hi,
i need to sort hash in descending order.
but the issue is , in hash, i have key as integer value and the value
associated with that key is string
so when i do sort it does not really sort the hash on the key level
i used follwoing code
foreach my $key (sort { $hash_fin{$b
d of help. I judged that Chris may well have
RD> trouble with anonymous hashes and Schwartzian transforms and, as I
RD> wrote, I believe it is important that software should be completely
RD> understood by its author.
you can also point out Sort::Maker which can do complex sorts with muc
On 11-03-17 03:23 PM, Rob Dixon wrote:
We have established that Chris's data is numeric. Your code is overkill.
No, it's not. Just because this case does not have the join character
in the data, does mean it will never happen. What the novice programmer
is going to do is decide that this te
On 17/03/2011 18:43, Shawn H Corey wrote:
On 11-03-17 02:04 PM, Rob Dixon wrote:
A beginners list isn't the place to introduce arbitrarily complex Perl
constructs. Replies have to be sensitive to the ability of the OP or
they may co
On the other hand, telling them to use a kluge to get the re
On 11-03-17 02:04 PM, Rob Dixon wrote:
A beginners list isn't the place to introduce arbitrarily complex Perl
constructs. Replies have to be sensitive to the ability of the OP or
they may co
On the other hand, telling them to use a kluge to get the results they
want is very bad advice. Tell t
On 17/03/2011 17:22, Shawn H Corey wrote:
On 11-03-17 01:05 PM, Rob Dixon wrote:
If you are uncomfortable with arrays of hash references
Sooner or later every Perl programmer has to become comfortable with
complex data structures. Why not start now?
A beginners list isn't the place to intro
On 17/03/2011 17:22, Chris Stinemetz wrote:
From: Rob Dixon [mailto:rob.di...@gmx.com]
If you are uncomfortable with arrays of hash references, it may be
better for you to create an array of records containing just the four
fields you are interested in, and then sort that. Such a program is
On 11-03-17 01:05 PM, Rob Dixon wrote:
If you are uncomfortable with arrays of hash references
Sooner or later every Perl programmer has to become comfortable with
complex data structures. Why not start now?
--
Just my 0.0002 million dollars worth,
Shawn
Confusion is the first step
On 16/03/2011 14:58, Chris Stinemetz wrote:
> Shawn H Corey wrote:
>> On 11-03-16 09:26 AM, Chris Stinemetz wrote:
>>>
>>> I would like to print results in ascending order starting with $cell,
>>> $sect, and finally $carr.
>>
>> You would need
On Thu, Mar 17, 2011 at 11:04, Chris Stinemetz
wrote:
snip
> For some reason I am not getting the sorted list in my output file. Instead I
> am getting the following:
>
> bc8) HASH(0x100d0d78) HASH(0x100d15e8) HASH(0x100d0f28) HASH(0x100d0c58)
> HASH(0x100d1168) HASH(0x100d1678)
snip
You are g
On 11-03-17 11:04 AM, Chris Stinemetz wrote:
print OUTFILE "@sorted:\n";
for my $tuple ( @sorted ){
print "$tuple->{cell} $tuple->{sect} $tuple->{carr} $tuple->{RTD}\n";
}
--
Just my 0.0002 million dollars worth,
Shawn
Confusion is the first step of understanding.
Pr
my($cell,$sect,$carr,$RTD) =
($data[31],$data[32],$data[38],$data[261]);
push @array, {
cell => $cell,
sect => $sect,
carr => $carr,
RTD => $RTD,
On 11-03-16 10:58 AM, Chris Stinemetz wrote:
Where would I place print to see the results for validation?
Since @sorted contains the sorted data, anywhere after it gets the
sorted data.
--
Just my 0.0002 million dollars worth,
Shawn
Confusion is the first step of understanding.
Prog
Thanks,
Where would I place print to see the results for validation?
On 11-03-16 09:26 AM, Chris Stinemetz wrote:
> I would like to print results in ascending order starting with $cell, $sect,
> and finally $carr.
You would need to store the data in a large array, then sort it.
# un
On 11-03-16 09:26 AM, Chris Stinemetz wrote:
I would like to print results in ascending order starting with $cell, $sect,
and finally $carr.
You would need to store the data in a large array, then sort it.
# untested due lack of data
my @array = ();
while (<>)
{
chomp;
I would like to print results in ascending order starting with $cell, $sect,
and finally $carr.
I am getting the error:
Name "main::a" used only once: possible typo at ./DOband.pl line 6.
Name "main::b" used only once: possible typo at ./DOband.pl line 6.
Below is my code. Any help is greatly a
st_sort {
for (0..$#$a) {
$z=$$a[$_]<=>$$b[$_];
return $z if $z!=0
}
return 0
}
print "$$_[0],$$_[1]\n" for sort test_sort @array;
Do all of your arrays only have one or two elements? Or is this just an
example?
This is just an example. I saw this
John wrote:
Thanks for pointing out the indexing mistake. I've fixed that in the code
below, but the sorting is still correct. (I've also added "return 0" in
case $z is always 0, but I get the same sort results with or without it.)
The new array being sorted also shows tha
ou trying to accomplish with that?
}
}
print "$$_[0],$$_[1]\n" for sort my_sort @array;
First I thought I needed "for" to run from 0 to the larger of the
lengths
of @$a and @$b, but with the example code, Perl sorts the entries
correctly, even though "for"
r ( 0 .. $#$a ) {
return $x if 0!=($x=$$a[$_]<=>$$b[$_])
You are returning $x if $a->[$_] is not equal to $b->[$_], but if
$a->[$_] *is* *equal* *to* $b->[$_] you are returning what?
What exactly are you trying to accomplish with that?
}
}
print "$$_[0
I'm sorting arrays by comparing corresponding entries. Take this example:
@array = ([2,1],[2],[2,1],[1]);
sub my_sort {
for (0...@$a) {
return $x if 0!=($x=$$a[$_]<=>$$b[$_])
}
}
print "$$_[0],$$_[1]\n" for sort my_sort @array;
First I
marcos rebelo wrote:
For doing the Sort, you may consider the schwartzian_transform
sub schwartzian_transform(&@) {
my $compute = shift;
return map { $_->[1] }
sort { $a->[0] cmp $b->[0] }
map { [ $compute->(), $_ ] } @_;
}
schwartzian_transform { (
bstrings.
>
> you should always show sample input data and expected output (sorted
> data). just describing it even when simple can be different than the
> actual data.
>
> KW> I want to sort these space separated strings based on the middle of the
> KW> dash-separ
(sorted
data). just describing it even when simple can be different than the
actual data.
KW> I want to sort these space separated strings based on the middle of the
KW> dash-separated substring.
KW> The regex for the space-separated sub string is not exactly, but close to
KW> th
Hi;
I have a legacy Perl script that I need to modify.
The current output is a set of zero or more space separated strings where
each substring is a string of of three dash-separated substrings.
I want to sort these space separated strings based on the middle of the
dash-separated substring
On Sun, Jun 20, 2010 at 04:41, philge philip wrote:
> hi
>
> can someone tell me how i can sort by keys from a hash (huge data) stored
> using Data::Dumper?
snip
Data::Dumper can be configured through the use of its package
variables (or methods if you are using the OO version).
On Sunday 20 Jun 2010 11:41:42 philge philip wrote:
> hi
>
> can someone tell me how i can sort by keys from a hash (huge data) stored
> using Data::Dumper?
>
You need to do:
[code]
my @keys = sort { $a cmp $b } keys(%hash);
[/code]
Is it causing a memory overflow?
Regards,
hi
can someone tell me how i can sort by keys from a hash (huge data) stored using
Data::Dumper?
thanking you
philge
Hi Owen,
On Tuesday 11 May 2010 14:10:49 Owen wrote:
> I have this statement;
>
> foreach my $key ( keys %filehash ) {
> print "$key $filehash{$key}->[0]\t\t\t$filehash{$key}->[3]\t
> $filehash{$key}->[2]\t $filehash{$key}->[1]\n";
> }
>
> but
Owen asked:
> I have this statement;
>
> foreach my $key ( keys %filehash ) {
> print "$key $filehash{$key}->[0]\t\t\t$filehash{$key}->[3]\t
> $filehash{$key}->[2]\t $filehash{$key}->[1]\n";
> }
>
> but wish to sort the output by $filehash{
I have this statement;
foreach my $key ( keys %filehash ) {
print "$key $filehash{$key}->[0]\t\t\t$filehash{$key}->[3]\t
$filehash{$key}->[2]\t $filehash{$key}->[1]\n";
}
but wish to sort the output by $filehash{$key}->[0]. Is it possible? How
do I do this?
I can&
Robert Wohlfarth wrote:
> On Mon, Dec 7, 2009 at 10:29 PM, wrote:
>
>> I'm fairly new to perl but loving it. I've run into some trouble though...
>> Trying to sort a hash by it's key value, which is not a problem by itself;
>>
>> foreach(my $key
On Mon, Dec 7, 2009 at 10:29 PM, wrote:
> I'm fairly new to perl but loving it. I've run into some trouble though...
> Trying to sort a hash by it's key value, which is not a problem by itself;
>
> foreach(my $key (sort keys %channels)) {
>print $key;
>
Hi,
I'm fairly new to perl but loving it. I've run into some trouble though...
Trying to sort a hash by it's key value, which is not a problem by itself;
foreach(my $key (sort keys %channels)) {
print $key;
}
What I've been struggling with for the last hour or so
of
PP> keys.
that is incorrect. it all depends on the growth of the algorithm. key
extraction can be the same work as comparisons but it becomes O(N). note
that with a straight call to sort() the comparison must also do key
extraction. if the keys are just a list of strings or numbers, th
2009/11/9 Michael Alipio :
> Hi,
>>
>> Do you need the fastest possible sort?
>
> I'm not even sure if I really need to worry about all these
> sorting techniques. My program just reads a text file
> (wordlist). It might be megabyte-sized or probably few
&g
On Monday 09 Nov 2009 19:40:29 Uri Guttman wrote:
> >>>>> "MA" == Michael Alipio writes:
>
> MA> i'm planning to sort an input file (which was File::Slurp'ed, most
> MA> likely megabyte-sized file) in various ways. I did some readings
>
Hi,
>
> Do you need the fastest possible sort?
I'm not even sure if I really need to worry about all these
sorting techniques. My program just reads a text file
(wordlist). It might be megabyte-sized or probably few
gigabytes (i might also add size checking on this to be
saf
2009/11/9 Michael Alipio :
> Hi,
>
> i'm planning to sort an input file (which was File::Slurp'ed, most likely
> megabyte-sized file) in various ways. I did some readings and learned several
> methods
> that people have come up with in recent years. So to summarize,
1 - 100 of 755 matches
Mail list logo