I like to define a value subroutine.
sub myvalue {
return uc($options{$_[0]}->{type} // "")
}
This particular one returns the empty string ("") if
$options{$_[0]}->{type} is undefined.
Now the sort becomes:
sort {myvalue($a) cmp myvalue($b)} keys %options
This code is
> On Apr 11, 2017, at 6:13 AM, Mike Martin wrote:
>
> Hi
>
> I have the following code as an example against a hash of hashes, to sort by
> hashrf key
>
> foreach my $opt (sort {uc($options{$b}->{type}) cmp uc($options{$a}->{type})}
> keys %options){
>my
Hi
I have the following code as an example against a hash of hashes, to sort
by hashrf key
foreach my $opt (sort {uc($options{$b}->{type}) cmp
uc($options{$a}->{type})} keys %options){
my $type=$options{$opt}->{vtype};
$video_type->append_text($type) if defined($type)
set and how it gets sorted (number vs string, etc.). it makes
sorting into a declarative problem instead of a coding problem.
uri
do'nt worry, that's what I'm
Thanks a lot for forcing me to study sorting in perl.
This morning I read sort_paper[*] apparently written by someone expert
On 08/23/2012 02:54 AM, Salvador Fandino wrote:
It's a pity Sort::Maker not in Debian
There is also Sort::Key, available in Debian testing and unstable, and
which is usually faster than Sort::Maker and also Sort::Key::Radix, even
faster when sorting by numeric keys but not available
::Radix, even
faster when sorting by numeric keys but not available in Debian.
use Sort::Key qw(ukeysort);
my @sorted = ukeysort { /^(\d+)-(\d+)/
or die bad key $_;
$1 * 100 + $2 } @data;
The 'u' prefix in 'ukeysort' specifies
sorting by numeric keys but not available in Debian.
use Sort::Key qw(ukeysort);
my @sorted = ukeysort { /^(\d+)-(\d+)/
or die bad key $_;
$1 * 100 + $2 } @data;
The 'u' prefix in 'ukeysort' specifies that the sorting key
);
+$test-{sorters}{$sort_name} = $sorter ;
+}
+}
+}
+1;
+}
+
sub count_tests {
my( $tests, $default_styles ) = @_ ;
Name main::bench used only once: possible typo at t/arrays.t line 1.
Sorting 100 elements of 'arrays of strings'
Benchmark: running GRT, SK, ST, gold, orcish
string, etc.). it makes
sorting into a declarative problem instead of a coding problem.
uri
do'nt worry, that's what I'm
Thanks a lot for forcing me to study sorting in perl.
This morning I read sort_paper[*] apparently written by someone expert
with the subject, and also Chapter 2 item 22
Hello List,
I am trying to sort a hash of arrays ( example below: )
I would the sort to sort in ascending order the first index of the array
then the second index of the array.
So in this example the arrays would sort to:
97,2,120,65
219,1,30,33
280,3,230,90
462,2,270,65
$VAR1 = {
On Tue, 21 Aug 2012 15:05:33 -0500
Chris Stinemetz chrisstinem...@gmail.com wrote:
I am trying to sort a hash of arrays ( example below: )
I would the sort to sort in ascending order the first index of the
array then the second index of the array.
What have you tried so far? Can we see the
On Tue, Aug 21, 2012 at 3:11 PM, Shawn H Corey shawnhco...@gmail.comwrote:
On Tue, 21 Aug 2012 15:05:33 -0500
Chris Stinemetz chrisstinem...@gmail.com wrote:
I am trying to sort a hash of arrays ( example below: )
I would the sort to sort in ascending order the first index of the
array
. The first index
of your array is 0, and sorting by the indices is a no-operation.
What you want to do is sort the list of keys returned by the keys() function.
You do this by supplying a subroutine reference to the sort function that
returns a negative value, zero, or a positive value
believe you mean first element rather than first index. The first index
of your array is 0, and sorting by the indices is a no-operation.
What you want to do is sort the list of keys returned by the keys() function.
You do this by supplying a subroutine reference to the sort function
I will leave it to you to write an actual program incorporating these
ideas.
Thank you Jim for the excelent explanation.
This seems to do the trick.
foreach my $cellNo ( sort { $hash{$a}-[0] = $hash{$b}-[0] ||
$hash{$a}-[1] = $hash{$b}-[1] } keys %hash ) {
print join( \0, @{
On 21/08/12 22:05, Chris Stinemetz wrote:
Hello List,
I am trying to sort a hash of arrays ( example below: )
I would the sort to sort in ascending order the first index of the array
then the second index of the array.
So in this example the arrays would sort to:
97,2,120,65
On 08/21/2012 05:33 PM, Eduardo wrote:
On 21/08/12 22:05, Chris Stinemetz wrote:
Hello List,
I am trying to sort a hash of arrays ( example below: )
I would the sort to sort in ascending order the first index of the array
then the second index of the array.
So in this example the arrays
On 22/08/12 00:35, Uri Guttman wrote:
On 08/21/2012 05:33 PM, Eduardo wrote:
On 21/08/12 22:05, Chris Stinemetz wrote:
Hello List,
I am trying to sort a hash of arrays ( example below: )
I would the sort to sort in ascending order the first index of the
array
then the second index of
need to do is code up how you extract each key from the data set
and how it gets sorted (number vs string, etc.). it makes sorting into a
declarative problem instead of a coding problem.
uri
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h
On 17/05/2012 23:19, Shawn H Corey wrote:
On 12-05-17 05:24 PM, Chris Stinemetz wrote:
push(@fields, $Icell,$Isect,$Ichan,$cfc,$cfcq,$rtd);
# push an anonymous array for each record
push @fields, [ $Icell,$Isect,$Ichan,$cfc,$cfcq,$rtd ];
}
}
my @sorted_fields = sort {
$a-[0]= $b-[0]
I have an array @fields that contains 6 elements.
I would like to sort the array by
$fields[0],$fields[1],$fields[2],$fields[3],$fields[4],$fields[5] in
ascending order starting witht he first element before I print the
array.
I haven't been able to figure this out. Any help is greatly
On 12-05-17 03:36 PM, Chris Stinemetz wrote:
I would like to sort the array by
$fields[0],$fields[1],$fields[2],$fields[3],$fields[4],$fields[5] in
ascending order starting witht he first element before I print the
array.
Do you want the fields sorted or do you want records sorted? If you want
On 05/17/2012 04:52 PM, Shawn H Corey wrote:
On 12-05-17 03:36 PM, Chris Stinemetz wrote:
I would like to sort the array by
$fields[0],$fields[1],$fields[2],$fields[3],$fields[4],$fields[5] in
ascending order starting witht he first element before I print the
array.
Do you want the fields
Thank you Uri and Shawn.
I am getting the following error and not sure how to resolve:
I will also checkout the great suggestions Uri made.
Can't use string (3) as an ARRAY ref while strict refs in use at
./DBSRtest.pl line 51, line 999.
#!/usr/bin/perl
use warnings;
use strict;
use POSIX;
On 12-05-17 05:24 PM, Chris Stinemetz wrote:
Thank you Uri and Shawn.
I am getting the following error and not sure how to resolve:
I will also checkout the great suggestions Uri made.
Can't use string (3) as an ARRAY ref while strict refs in use at
./DBSRtest.pl line 51, line 999.
That's what the documentation says:
...
$json = $json-canonical([$enable])
If $enable is true (or missing), then the encode method will output JSON
objects by sorting their keys. This is adding a comparatively high
overhead.
...
So I guess you'd have to use something like that:
my $ret_json
in the script this is all i am using JSON as:
...
use JSON::XS;
...
$return_json_text = encode_json $tmp_hash;
this variable ($return_json_text) is then used to display values. I need this
to be orderd, but not able to figure how to order the outcome??? I read about
$enabled =
To: perl list beginners@perl.org
Cc:
Sent: Sunday, February 5, 2012 10:04 PM
Subject: need guidance on encode JSON and sorting
in the script this is all i am using JSON as:
...
use JSON::XS;
...
$return_json_text = encode_json $tmp_hash;
this variable ($return_json_text) is then used
-20 22:24:36 value is some text
- Original Message -
From: Rajeev Prasad rp.ne...@yahoo.com
To: perl list beginners@perl.org
Cc:
Sent: Sunday, February 5, 2012 10:20 PM
Subject: Re: need guidance on encode JSON and sorting
I tried below but getting err:
my $json = JSON::XS
Hi Rob,
Thanks for your response and to everyone else who had given their thoughts,
especially John. This whole exercise is turning out to be a fun way of
learning arrays and print formatting.
I tried the script that you suggested and it is giving some error and not
sure how to get around it.
On 30/10/2011 13:20, newbie01 perl wrote:
Hi Rob,
Thanks for your response and to everyone else who had given their thoughts,
especially John. This whole exercise is turning out to be a fun way of
learning arrays and print formatting.
I tried the script that you suggested and it is giving some
On 24/10/2011 21:35, John W. Krahn wrote:
You forgot the part where the OP wants to sort the output. :-)
I thought I didn't have enough information to know how the OP wanted the
report sorted, but I see from the attacked shell script that the
original lines from the df output are sorted before
:-)
Plus it is a good exercise to learn Perl arrays and sorting too.
Any advise/feedback much appreciated. Thanks in advance.
The program below seems to do the job.
Hope it helps,
Rob
use strict;
use warnings;
use List::Util qw/max/;
sub kb_to_mb {
sprintf %.0f-MB, shift(@_) / 1024;
}
sub
Rob Dixon wrote:
**OUTPUT**
FilesystemMBytes UsedAvail Capacity
Mount
-- - -
-
/dev/md/dsk/d1 3027-MB 2424-MB 542-MB 82% /
/proc
On 2011-10-22 17:37, timothy adigun wrote:
my($filesys,$mbytes,$used,$avail,$capacity,$mount)=(,);
Alternative:
$_ = for my ( $p, $q, $r, $s );
--
Ruud
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
Hi newbie01 perl,
Try the code below and see if it works for you, it works well on my
Ultimate Ubuntu OS.
Assumptions in the code below:
1. you must pass df to the perl script on the Command Line Interface *e.g
perl mydf.pl df*,
2. you don't have Perl6::Form installed, though you can get here
On Sat, Oct 22, 2011 at 11:37 AM, timothy adigun 2teezp...@gmail.com wrote:
my($filesys,$mbytes,$used,$avail,$capacity,$mount)=(,);
Declaring these variables here is useless (and initializing them
here is even more useless). :-/ The lack of whitespace is also
useless and makes it more
On Fri, Oct 21, 2011 at 10:18 PM, newbie01 perl newbie01.p...@gmail.com wrote:
At the moment am using
system(df -k /tmp/df_tmp.00);
To re-direct the df output. Am using df -k because some of the Solaris and
HP servers does not have df -h, by using df -k, am sure it will work on all
of
On Sat, Oct 22, 2011 at 3:00 PM, Brandon McCaig bamcc...@gmail.com wrote:
http://search.cpan.org/~abarclay/Filesys-DiskFree-0.06/DiskFree.pm
I guess the proper way to post a CPAN link is with the 'permalink':
http://search.cpan.org/perldoc?Filesys::DiskFree
Regards,
--
Brandon McCaig
On Sat, Oct 22, 2011 at 4:57 PM, Brandon McCaig bamcc...@gmail.com wrote:
On Sat, Oct 22, 2011 at 11:37 AM, timothy adigun 2teezp...@gmail.com
wrote:
my($filesys,$mbytes,$used,$avail,$capacity,$mount)=(,);
Declaring these variables here is useless (and initializing them
here is even
On Sat, Oct 22, 2011 at 7:13 PM, Brian Fraser frase...@gmail.com wrote:
I say this without a bit of sarcasm: Feel blessed in your ignorance of
formats. The declarations on top are unfortunately needed (If it helps,
think of formats using lexical variables as closures).
But you shouldn't be
Learning Perl turns out to be the 6th edition.
Oh my! I thought to myself, perhaps mine might be about
the 4th or 5th edition - alas, it is the 2nd. Start
saving...
Tx rgds, GFStC.
On Fri, 21 Oct 2011 22:37:14 -0700
David Christensen dpchr...@holgerdanske.com wrote:
The canonical
using Korn shell. I am hoping that it
will run faster in Perl, John W. Krahn had proven that to be case lots of
times, thanks John :-)
Plus it is a good exercise to learn Perl arrays and sorting too.
Any advise/feedback much appreciated. Thanks in advance.
Sample output of the run using the Korn
On 10/21/2011 07:18 PM, newbie01 perl wrote:
Am trying to write/convert a customized df script...
I've attached a version of the script in Korn shell. ...
...
[input]
Filesystemkbytesused avail capacity Mounted on
/dev/md/dsk/d1 3099287 2482045 55525782%/
Brandon and Jim,
Thank you for the replies. They were very helpful. I have gotten past my
blockage.
Eric
On Aug 17, 2011, at 5:22 PM, Brandon McCaig wrote:
On Wed, Aug 17, 2011 at 5:59 PM, ERIC KRAUSE erickra...@bft1.org wrote:
The problem for me is the line endings I think. When I open the
-Original Message-
From: Matt [mailto:lm7...@gmail.com]
Sent: Tuesday, August 16, 2011 10:04
To: beginners@perl.org
Subject: Sorting a String
I believe you can sort an array like so:
sort @my_array;
I need to sort a string though.
I have $a_string that contains:
4565 line1
2345 line2
Hi,
On Tue, 16 Aug 2011 11:09:35 -0500
Wagner, David --- Sr Programmer Analyst --- CFS david.wag...@fedex.com
wrote:
-Original Message-
From: Matt [mailto:lm7...@gmail.com]
Sent: Tuesday, August 16, 2011 10:04
To: beginners@perl.org
Subject: Sorting a String
I believe you can
Hello all,
I am beating my head against the wall, any help would be appreciated.
I have a file:
/ // / m / cvfbcbf/ A123/ / / ///
/ // / m / cvfbcbf/ A234/ / / ///
/ // / m / cvfbcbf/ B123/ / / ///
There is spaces in the
On 8/17/11 Wed Aug 17, 2011 2:59 PM, ERIC KRAUSE erickra...@bft1.org
scribbled:
Hello all,
I am beating my head against the wall, any help would be appreciated.
I have a file:
/ // / m / cvfbcbf/ A123/ / / ///
/ // / m / cvfbcbf/ A234/ / / ///
On Wed, Aug 17, 2011 at 5:59 PM, ERIC KRAUSE erickra...@bft1.org wrote:
The problem for me is the line endings I think. When I open the
file and read in one line, I get the whole file. I think the
line endings are ^p (MS paragraph markers), but I can't open
the file to view them. The files are
Shlomi Fish wrote:
Wagner, David --- Sr Programmer Analyst --- CFSdavid.wag...@fedex.com
wrote:
Since a \n is at end, then could use split like:
for my $dtl ( sort {$a= $b} split(/\n/, $a_string) ) {
One can also do split(/^/m, $a_string) to split into lines while preserving
I believe you can sort an array like so:
sort @my_array;
I need to sort a string though.
I have $a_string that contains:
4565 line1
2345 line2
500 line3
etc.
Obviously \n is at end of every line in the string. I need it sorted.
How would I approach this?
--
To unsubscribe, e-mail:
sort like string or like numbers?
On Tue, Aug 16, 2011 at 18:04, Matt lm7...@gmail.com wrote:
I believe you can sort an array like so:
sort @my_array;
I need to sort a string though.
I have $a_string that contains:
4565 line1
2345 line2
500 line3
etc.
Obviously \n is at end of every
On Tue, Aug 16, 2011 at 12:04 PM, Matt lm7...@gmail.com wrote:
I believe you can sort an array like so:
sort @my_array;
I need to sort a string though.
I have $a_string that contains:
4565 line1
2345 line2
500 line3
etc.
Obviously \n is at end of every line in the string. I need it
Matt wrote:
I believe you can sort an array like so:
sort @my_array;
That should be:
@my_array = sort @my_array;
I need to sort a string though.
I have $a_string that contains:
4565 line1
2345 line2
500 line3
etc.
Obviously \n is at end of every line in the string. I need it sorted.
On Mon, Aug 08, 2011 at 10:40:12AM +0530, Ramprasad Prasad wrote:
Using the system linux sort ... Does not help.
On my dual quad core machine , (8 gb ram) sort -n file takes 10
minutes and in the end produces no output.
Did you set any other options?
At a minimum you should set -T to tell
On Aug 8, 2011 12:11 AM, Ramprasad Prasad ramprasad...@gmail.com wrote:
Using the system linux sort ... Does not help.
On my dual quad core machine , (8 gb ram) sort -n file takes 10
minutes and in the end produces no output.
I had a smaller file and 32g to play with on a dual quad core
On Mon, Aug 08, 2011 at 09:25:48AM -0400, shawn wilson wrote:
On Aug 8, 2011 12:11 AM, Ramprasad Prasad ramprasad...@gmail.com wrote:
Using the system linux sort ... Does not help.
On my dual quad core machine , (8 gb ram) sort -n file takes 10
minutes and in the end produces no output.
Hi Ramprasad,
On Sun, 7 Aug 2011 20:58:14 +0530
Ramprasad Prasad ramprasad...@gmail.com wrote:
I have a file that contains records of customer interaction
The first column of the file is the batch number(INT) , and other columns
are date time , close time etc etc
I have to sort the entire
On 11-08-08 10:23 AM, Shlomi Fish wrote:
I suggest splitting the files into bins. Each bin will contain the records with
the batch numbers in a certain range (say 0-999,999 ; 1,000,000-1,999,999,
etc.). You should select the bins so the numbers are spread more or less
evenly. Then you sort each
On Mon, Aug 8, 2011 at 10:10, Paul Johnson p...@pjcj.net wrote:
On Mon, Aug 08, 2011 at 09:25:48AM -0400, shawn wilson wrote:
On Aug 8, 2011 12:11 AM, Ramprasad Prasad ramprasad...@gmail.com wrote:
Using the system linux sort ... Does not help.
On my dual quad core machine , (8 gb ram)
I have a file that contains records of customer interaction
The first column of the file is the batch number(INT) , and other columns
are date time , close time etc etc
I have to sort the entire file in order of the first column .. but the
problem is that the file is extremely huge.
For the
On 11-08-07 11:28 AM, Ramprasad Prasad wrote:
I have a file that contains records of customer interaction
The first column of the file is the batch number(INT) , and other columns
are date time , close time etc etc
I have to sort the entire file in order of the first column .. but the
problem
On 11-08-07 11:46 AM, Ramprasad Prasad wrote:
I used a mysql database , but the order by clause used to hang the
process indefinitely
If I sort files in smaller chunks how can I merge them back ??
Please use Reply All when responding to a message on this list.
You need two temporary files
On 7 August 2011 21:24, Shawn H Corey shawnhco...@gmail.com wrote:
On 11-08-07 11:46 AM, Ramprasad Prasad wrote:
I used a mysql database , but the order by clause used to hang the
process indefinitely
If I sort files in smaller chunks how can I merge them back ??
Please use Reply All when
On 2011-08-07 17:28, Ramprasad Prasad wrote:
I have a file that contains records of customer interaction
The first column of the file is the batch number(INT) , and other columns
are date time , close time etc etc
I have to sort the entire file in order of the first column .. but the
problem
:01 AM
Subject: Re: Sorting an extremely LARGE file
On 7 August 2011 21:24, Shawn H Corey shawnhco...@gmail.com wrote:
On 11-08-07 11:46 AM, Ramprasad Prasad wrote:
I used a mysql database , but the order by clause used to hang the
process indefinitely
If I sort files in smaller chunks how
On Sun, Aug 07, 2011 at 08:58:14PM +0530, Ramprasad Prasad wrote:
I have a file that contains records of customer interaction
The first column of the file is the batch number(INT) , and other columns
are date time , close time etc etc
I have to sort the entire file in order of the first
On Aug 7, 2011 1:15 PM, Paul Johnson p...@pjcj.net wrote:
On Sun, Aug 07, 2011 at 08:58:14PM +0530, Ramprasad Prasad wrote:
I have a file that contains records of customer interaction
The first column of the file is the batch number(INT) , and other
columns
are date time , close time etc
On 11-08-07 03:20 PM, shawn wilson wrote:
It can be sped up (slightly) with an index.
Indexes in SQL don't normally speed up sorting. What they're best at is
selecting a limited number of records, usually less than 10% of the
total. Otherwise, they just get in the way.
The best you can
On 07/08/2011 20:30, Shawn H Corey wrote:
On 11-08-07 03:20 PM, shawn wilson wrote:
It can be sped up (slightly) with an index.
Indexes in SQL don't normally speed up sorting. What they're best at is
selecting a limited number of records, usually less than 10% of the
total. Otherwise
On Sun, Aug 7, 2011 at 15:58, Rob Dixon rob.di...@gmx.com wrote:
On 07/08/2011 20:30, Shawn H Corey wrote:
On 11-08-07 03:20 PM, shawn wilson wrote:
It can be sped up (slightly) with an index.
Indexes in SQL don't normally speed up sorting. What they're best at is
selecting a limited
RP == Rajeev Prasad rp.ne...@yahoo.com writes:
RP hi, you can try this: first get only that field (sed/awk/perl)
RP whihc you want to sort on in a file. sort that file which i assume
RP would be lot less in size then your current file/table. then run a
RP loop on the main file using
Using the system linux sort ... Does not help.
On my dual quad core machine , (8 gb ram) sort -n file takes 10
minutes and in the end produces no output.
when I put this data in mysql , there is an index on the order by
field ... But I guess keys don't help when you are selecting the
entire
On Sun, Aug 7, 2011 at 22:10, Ramprasad Prasad ramprasad...@gmail.com wrote:
[snip]
I guess there is a serious need for re-architecting , rather than
create such monstrous files, but when people work with legacy systems
which worked fine when there was lower usage and now you tell then you
Shlomi,
See far bottom for my updated code.
Chris Stinemetz
-Original Message-
From: Shlomi Fish [mailto:shlo...@iglu.org.il]
Sent: Tuesday, February 01, 2011 4:18 AM
To: beginners@perl.org
Cc: Chris Stinemetz
Subject: Re: sorting report
Hi Chris,
a few comments on your code
I bottom posted. Any help is greatly appreciated.
Chris
-Original Message-
From: Chris Stinemetz [mailto:cstinem...@cricketcommunications.com]
Sent: Tuesday, February 01, 2011 8:03 AM
To: Shlomi Fish; beginners@perl.org
Subject: RE: sorting report
Shlomi,
See far bottom for my
On 01/02/2011 14:02, Chris Stinemetz wrote:
#!/usr/bin/perl
use warnings;
use strict;
use IO::Handle;
RAW-format_lines_per_page(100); # I will change this once I get strict
pragma to work.
format RAW_TOP =
I would like to sort my final report in the following order:
$data[31],$data[32],$data[38]
How would I add this into my following program to get the report sorted this
way?
Thanks in advance.
Chris
#!/usr/bin/perl
use warnings;
#use strict;
use FileHandle;
use IO::Handle;
Hi all,
The following perl program, for sorting files in a directory, without using
any OS specific command, ordered by modified timestamp is not working.
Please help.
*Perl Program*
#!perl.exe
use strict;
use warnings;
my $directory_name;
print This program print the files in ascending
On 10-12-01 07:19 AM, Amit Saxena wrote:
print Sorted listing of files in$directory_name directory are as follows
:-\n;
my $j;
foreach $j ( @files_in_directory )
foreach $j ( @sorted_files_in_directory )
{
print $j . \n;
}
print \n;
--
Just my 0.0002 million dollars worth,
Amit Saxena wrote:
Hi all,
Hello,
The following perl program, for sorting files in a directory, without using
any OS specific command, ordered by modified timestamp is not working.
Please help.
*Perl Program*
#!perl.exe
use strict;
use warnings;
my $directory_name;
print This program
John W. Krahn wrote:
Amit Saxena wrote:
my @sorted_files_in_directory;
@sorted_files_in_directory = sort { (stat($a))[9]= (stat($b))[9] }
If you read the documentation for readdir you will see where it says:
If you're planning to filetest the return values out of a
readdir, you'd better
On 10-12-01 09:57 AM, John W. Krahn wrote:
Or just:
print map( $_\n, @files_in_directory ), \n;
print map( $_\n, @sorted_files_in_directory ), \n;
--
Just my 0.0002 million dollars worth,
Shawn
Programming is as much about organization and communication
as it is about coding.
The
On Wednesday 01 December 2010 16:57:07 John W. Krahn wrote:
Amit Saxena wrote:
Hi all,
{
next if ( ( $filename eq . ) or ( $filename eq .. ) );
push ( @files_in_directory, $filename );
}
Since all you are doing is populating the array you could
On Dec 1, 7:31 am, jwkr...@shaw.ca (John W. Krahn) wrote:
Correction:
my @sorted_files_in_directory =
map $_-[ 1 ],
sort { $a-[ 0 ] = $b-[ 0 ] }
map { ( stat $directory_name/$_ )[ 9 ], $_ }
map { [ ( stat $directory_name/$_ )[ 9 ], $_ ] }
On Jun 20, 1:39 am, philg...@yahoo.com (philge philip) wrote:
hi
can someone tell me how i can sort by keys from a hash (huge data) stored in
a DB_File?
You might try a merge-sort - check CPAN.
Another possibility: re-write the existing DB_File
to use a DB_Tree format which by default
hi
can someone tell me how i can sort by keys from a hash (huge data) stored in a
DB_File?
thanking you
philge
Many thanks to Scott, Shawn, Paul, Jenda, and Uri. I've learned
something from each of you, and appreciate your taking the time to help!
Rick
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/
I need to sort the keys in a hash. The keys are the question number
and the values are the student's answer. A numeric sort with = won't
work since retaking a missed question (say, 2) produces the new key,
2h with its new answer. A representative hash might look like this
1 = b
2h = c
3 =
Rick Triplett wrote:
I need to sort the keys in a hash. The keys are the question number and
the values are the student's answer. A numeric sort with = won't work
since retaking a missed question (say, 2) produces the new key, 2h with
its new answer. A representative hash might look like this
On Tue, Oct 13, 2009 at 11:09:09AM -0500, Rick Triplett wrote:
I need to sort the keys in a hash. The keys are the question number and
the values are the student's answer. A numeric sort with = won't work
since retaking a missed question (say, 2) produces the new key, 2h with
its new
Date sent: Wed, 14 Oct 2009 11:03:13 -0400
From: Shawn H Corey shawnhco...@gmail.com
To: Rick Triplett r...@reason.net
Copies to: Perl Beginners beginners@perl.org
Subject:Re: Sorting mixed alphanumerics
Rick
Jenda Krynicky wrote:
ST is an overkill if the extraction is simple.
Especially if the number of items is fairly small.
Actually if the extraction is really simple and the extracted key is
not so small, than ST may perform worse than an ordinary sort doing
the extraction within the
in the sort. All the rest is just copy paste.
and if you can't generate an ST easily enough, try Sort::Maker. it can
do that and 3 other sort styles. when you have a short list of data,
speed of sorting isn't relevant, but easy of coding multikey sorts is
always important. sort::maker allows for easy
-Original Message-
From: Rick Triplett [mailto:r...@reason.net]
Sent: Tuesday, October 13, 2009 12:09 PM
To: Perl Beginners
Subject: Sorting mixed alphanumerics
I need to sort the keys in a hash. The keys are the question number
and the values are the student's answer. A numeric sort
From: Shawn H Corey shawnhco...@gmail.com
Jenda Krynicky wrote:
ST is an overkill if the extraction is simple.
Especially if the number of items is fairly small.
Actually if the extraction is really simple and the extracted key is
not so small, than ST may perform worse than an
Hi,
I need an order for hash by user preferences. Because the criterion to order
the hash entries a not numerical and not should sorted alphabetical, I tried
following
3 %hashToSort = (
4 a = one,
5 b = two,
6 c = three,
7 );
@keys = sort { qw(a, b, c) } (keys
On Wed, Jul 8, 2009 at 15:09, Alexander
Mülleralexan.muel...@fh-wolfenbuettel.de wrote:
Hi,
I need an order for hash by user preferences. Because the criterion to order
the hash entries a not numerical and not should sorted alphabetical, I tried
following
3 %hashToSort = (
4 a =
Hi,
If I have a loop that for each run creates
while (FILE){
my $value =~ /^\d/;
$myhash{$mykey}-{'subkey'} = $value;
}
Normally, if I only want to sort $myhash through it's values, I would do
something like:
foreach (sort { $a = $b } keys %myhash){
print $myhash{$_}\n;
}
what if i
1 - 100 of 685 matches
Mail list logo