Re: Sorting an extremely LARGE file

2011-08-08 Thread Shlomi Fish
Hi Ramprasad, On Sun, 7 Aug 2011 20:58:14 +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 t

Re: Sorting an extremely LARGE file

2011-08-08 Thread Shawn H Corey
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 b

Re: Sorting an extremely LARGE file

2011-08-08 Thread shawn wilson
On Mon, Aug 8, 2011 at 10:10, Paul Johnson wrote: > On Mon, Aug 08, 2011 at 09:25:48AM -0400, shawn wilson wrote: >> On Aug 8, 2011 12:11 AM, "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 >>

Re: Warnings when sorting by hashref

2017-04-11 Thread Jim Gibson
> 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 $type=$options{$opt}->{vt

Re: Warnings when sorting by hashref

2017-04-11 Thread Chris Fedde
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 unteste

Explaining myself correctly RE: SORTING BY DATE

2001-08-06 Thread Daniel Falkenberg
List, Please accept my sicerest apologies for not explaining myself correctly in my last post (RE: SORTING BY DATE). What I really need to be able to do is have my script display the date as YEAR () MONTH (xx) DAY (xx) For egsamle todays date would be displayed as 20010807 At the moment

RE: sorting an id like a.12.34

2003-01-06 Thread Wagner, David --- Senior Programmer Analyst --- WGO
How do you want to sort the data? by second field, third field, first field? YOu haven't really stated your problem as such. Wags ;) -Original Message- From: Konrad Foerstner [mailto:[EMAIL PROTECTED]] Sent: Monday, January 06, 2003 08:23 To: [EMAIL PROTECTED] Subject: so

RE: sorting an id like a.12.34

2003-01-06 Thread Dan Muey
23 AM To: [EMAIL PROTECTED] Subject: sorting an id like a.12.34 Hi Folks! My problem: I have a file of ids like a.12.34 or z.9.234 and want to sort it into a new file. As the sort function sorts digit by digit I can't use it (not so easy). Additionally the data file is quite big (11M) so I

Re: sorting an id like a.12.34

2003-01-06 Thread david
Konrad Foerstner wrote: > Hi Folks! > > My problem: I have a file of ids like a.12.34 or z.9.234 and want to sort > it into a new file. As the sort function sorts digit by digit I can't use > it (not so easy). Additionally the data file is quite big (11M) so I don't > know if it is okay to work w

RE: Sorting a 2dim array / Spreadsheet::WriteExcel

2003-01-30 Thread Timothy Johnson
how about: foreach(sort {$a->[0] cmp $b->[0]} @AoA){ #sort by the first element of the array created #by dereferencing each element of @AoA -Original Message- From: Paul Kraus [mailto:[EMAIL PROTECTED]] Sent: Thursday, January 30, 2003 1:32 PM To: 'Perl' Subject: Sort

RE: Sorting a 2dim array / Spreadsheet::WriteExcel

2003-01-30 Thread Kipp, James
> > I am dumping rows of an array into an excel file. I would like those > rows to be sorted. If I wanted them to be sorted by the first elements > how would I do it? Try this: @AoA = sort { $a->[0] cmp $b->[0] } @Aoa; > > Code > > #!/usr/bin/perl -w > use strict; > use Spreadsheet::Write

RE: Sorting a 2dim array / Spreadsheet::WriteExcel

2003-01-30 Thread Wagner, David --- Senior Programmer Analyst --- WGO
Paul Kraus wrote: > I am dumping rows of an array into an excel file. I would like those > rows to be sorted. If I wanted them to be sorted by the first elements > how would I do it? > > Code > > #!/usr/bin/perl -w > use strict; > use Spreadsheet::WriteExcel; > open IN, ($ARGV[0]); > my @AoA;

Re: Sorting a 2dim array / Spreadsheet::WriteExcel

2003-01-30 Thread Janek Schleicher
On Thu, 30 Jan 2003 16:32:04 +, Paul Kraus wrote: > I am dumping rows of an array into an excel file. I would like those > rows to be sorted. If I wanted them to be sorted by the first elements > how would I do it? > > Code > I haven't looked to your code, but so

Re: Array sorting (yet another trains question)

2003-03-29 Thread Peter Scott
In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] (Rob Richardson) writes: >Greetings! > >In the train schedule program that you are all probably heartily sick >of by now, I have added a ScheduleDay class that represents all trains >running on a given day. It has a method that returns an array of

Re: Array sorting (yet another trains question)

2003-03-29 Thread Rob Richardson
Peter, Thanks for your reply. My responses are in-line below. Rob --- Peter Scott <[EMAIL PROTECTED]> wrote: > In article <[EMAIL PROTECTED]>, > [EMAIL PROTECTED] (Rob Richardson) writes: > >sub GetTrainsByTime > >{ > > my $self = shift; > > my @result; > > my @temp; > > my $a

Re: Array sorting (yet another trains question)

2003-03-29 Thread Wiggins d'Anconia
Rob Richardson wrote: (1) If you wanted to put the keys of a hash into an array, just do it all at once: @temp = keys %$self I am not putting the keys of the hash into the temporary array. I'm putting the values of the hash into the array. In that case, perldoc -f values, 'values' does the s

Re: Array sorting (yet another trains question)

2003-03-29 Thread John W. Krahn
Rob Richardson wrote: > > --- Peter Scott <[EMAIL PROTECTED]> wrote: > > > > (2) If you want to sort the keys of a hash, there's no need to put > > them into an array. sort takes a list as input: > > > > return sort { $a->GetCrewCall cmp $b->GetCrewCall } keys %self > > Since I am not usin

Re: Array sorting (yet another trains question)

2003-03-30 Thread Peter Scott
In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] (Rob Richardson) writes: >--- Peter Scott <[EMAIL PROTECTED]> wrote: >> In article <[EMAIL PROTECTED]>, >> [EMAIL PROTECTED] (Rob Richardson) writes: >> >sub GetTrainsByTime >> >{ >> >my $self = shift; >> >my @result; >> >my @temp; >>

Sorting files by date (contained in file)

2002-07-08 Thread Shannon Murdoch
Hi all, I have a list of 40 or so files that need to be sorted into an array by article date (found in first line of each file in the form DD-MM-). I can't figure out how to go about it successfully... Can anyone help me out please?? Thanks in advance! Current method is as follows: use T

Re: sorting a hash - multiple key fields

2002-09-17 Thread Ramprasad A Padmanabhan
Use this . I think you wud do better later to move the sort function to a seperate sub foreach $key (sort { ($$h{$a}{taste} eq $$h{$b}{taste} ) ? $$h{$a}{name} cmp $$h{$b}{name}: $$h{$a}{taste} \cmp $$h{$b}{taste} } (keys %$h)) { print "$key \n"; } Jeff Aa wrote: > Folks, >

RE: sorting a hash - multiple key fields

2002-09-17 Thread Jeff AA
> -Original Message- > From: Ramprasad A Padmanabhan [mailto:[EMAIL PROTECTED]] > Sent: 17 September 2002 14:44 > To: [EMAIL PROTECTED]; Jeff Aa > Cc: [EMAIL PROTECTED] > Subject: Re: sorting a hash - multiple key fields > > > Use this . I think you wud

Re: sorting a hash - multiple key fields

2002-09-17 Thread david
Jeff Aa wrote: > Folks, > > I want to sort my masked hashes into neat little piles for easier > digestion: > Please note this is _example_ data 8-) > > my $h = { > a => { name => 'apple', taste => 3 }, > b => { name => 'peach', taste => 2 }, > c => { name => 'banana', taste => 2 }, > } >

RE: sorting a hash - multiple key fields

2002-09-17 Thread Jeff
Thanks for the response - some questions on your recommendation below: -Original Message- From: david [mailto:[EMAIL PROTECTED]] Sent: 17 September 2002 19:06 To: [EMAIL PROTECTED] Subject: Re: sorting a hash - multiple key fields > the return statment is uneccessary. try someth

RE: sorting a hash - multiple key fields

2002-09-17 Thread david
Jeff wrote: > Thanks for the response - some questions on your recommendation below: > > -Original Message- > From: david [mailto:[EMAIL PROTECTED]] > Sent: 17 September 2002 19:06 > To: [EMAIL PROTECTED] > Subject: Re: sorting a hash - multiple key fields > &

RE: sorting a hash - multiple key fields

2002-09-17 Thread Ramprasad A Padmanabhan
On Tue, 2002-09-17 at 19:58, Jeff AA wrote: > > > -Original Message- > > From: Ramprasad A Padmanabhan [mailto:[EMAIL PROTECTED]] > > Sent: 17 September 2002 14:44 > > To: [EMAIL PROTECTED]; Jeff Aa > > Cc: [EMAIL PROTECTED] > > Subject: R

sorting data (more than one scalar involved)

2002-09-26 Thread Steveo
300 1000 I can open and close the ascii text file. Whats an approach for going about sorting this data? Steveo (aka Haiku) [EMAIL PROTECTED] www.linuxhaiku.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

sorting a hash by using a function

2002-11-03 Thread Zysman, Roiy
Hi All, How can i get the hash reference when i use a function to sort that hash. e.g. i want to sort the hash according to is values I can do something like this sort {$hash{$a} cmp $hash{$b}} (keys %hash); but i want to sort it by using a call to a function , something like this foreach my $item

Re: sorting hash list for CGI Form

2004-03-09 Thread James Edward Gray II
On Mar 9, 2004, at 3:39 PM, Scott Taylor wrote: Hello all, Howdy. When I populate this hash (%SrcIDs) from "SELECT id, desc, from myTable order by desc" it doesn't order by the description field "desc". (printing each row in the while loop show that the SQL is sorted) See inlined change bel

Re: sorting hash list for CGI Form

2004-03-09 Thread R. Joseph Newton
Scott Taylor wrote: > Hello all, > > When I populate this hash (%SrcIDs) from "SELECT id, desc, from myTable > order by desc" it What does "it" refer to here? If you mean the SQL engine, which does care about the content of order clauses, you are mistaken. Your data set is returned in the prope

avoid repitive code while sorting hash arrays

2003-09-19 Thread Ramprasad A Padmanabhan
x27;, 'uid' => 515, 'gid' => 515 }, ); Now I want to sort on either of the fields 'uname' 'uid' 'gid' and ascending or descending Then my so

Re: File sorting by a specific date

2003-10-17 Thread John W. Krahn
Paul Harwood wrote: > > I want to search a directory of log files and populate a list of those > log files ONLY if they match today's date (localtime). > > $logs = 'c:\logs\W3SVC1'; > opendir LOGS, "$logs" or die "Can't open directory: $!\n"; > my @files = grep /\.TXT$/, readdir LOGS; > > #Righ

Re: File sorting by a specific date

2003-10-21 Thread Paul Harwood
This isn't working for some reason. The $date scalar seems unchanged throughout. Paul Harwood wrote: > > I want to search a directory of log files and populate a list of those > log files ONLY if they match today's date (localtime). > > $logs = 'c:\logs\W3SVC1'; > opendir LOGS, "$logs" or die "C

Re: File sorting by a specific date

2003-10-21 Thread Kevin Pfeiffer
Hi, In article <[EMAIL PROTECTED]>, Paul Harwood purportedly wrote: > This isn't working for some reason. The $date scalar seems unchanged > throughout. > > Paul Harwood wrote: >> >> I want to search a directory of log files and populate a list of those >> log files ONLY if they match today's

Sorting an array based on hash values

2002-06-20 Thread Kevin Old
Hello all, I have a hash with the key being the field name and the value being the order in which the field is to be displayed.like below: %order = ( DATE => '1', CPP => '2', ESN => '3', BTS => '4' ); I'm receiving an array that would look somethi

Re: Sorting a hash to user needs

2009-07-08 Thread Chas. Owens
On Wed, Jul 8, 2009 at 15:09, "Alexander Müller" 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" => "one", >   5 "b"

hash containing a hash, sorting keys help

2007-05-05 Thread Ken Foskey
I cannot get the syntax right for child lookup, Data::Dumper confirms that I have the structure as I expect (logic may be totally wrong though). I going to do a webpage pstree command. foreach my $child (sort keys( $parent{$pid} )) { dump_process( $child ); } Type of arg 1 to key

sorting array of array of array elements

2008-04-22 Thread Süleyman Gülsüner
Hi All, I am trying to sort some data, which originally came as an excel file. There are main titles, sub titles, sub sub titles and sub sub sub titles. They defined by using different levels of indents in the original file. I parse it and convert indents into spaces. Main titles are sorted by f

Re: Sorting the items in a directory

2007-04-27 Thread Jeff Pang
2007/4/27, Nigel Peck <[EMAIL PROTECTED]>: Hi, I have a list containing the names of all items in a directory. I want to sort it by non-directories first and then directories, with a secondary sort in alphabetical order. Hello, I've tested, this could work for you. my @items = map { $_->[0]

Re: Sorting the items in a directory

2007-04-27 Thread Jeff Pang
I'm sorry that just be clear you want the non-directory first,then simply change the codes to: my @items = map { $_->[0] } sort { $a->[1] <=> $b->[1] or $a->[0] cmp $b->[0] } map { -d $_ ? [$_,1] : [$_,0] } readdir DIR; 2007/4/27, Jeff Pang <[EMAIL PROTECTED]>: 2007/4/27,

Re: Sorting the items in a directory

2007-04-27 Thread Rob Dixon
Nigel Peck wrote: Hi, I have a list containing the names of all items in a directory. I want to sort it by non-directories first and then directories, with a secondary sort in alphabetical order. I currently have: my @items = sort { my $a_path = $a

Re: Sorting the items in a directory

2007-04-27 Thread John W. Krahn
Nigel Peck wrote: > > Hi, Hello, > I have a list containing the names of all items in a directory. I want > to sort it by non-directories first and then directories, with a > secondary sort in alphabetical order. > > I currently have: > > > my @items = sort { >

Re: Sorting the items in a directory

2007-04-27 Thread Nigel Peck
Thanks Jeff, thanks Rob. I used your solution Jeff and it's working a treat. Cheers, Nigel Rob Dixon wrote: Nigel Peck wrote: Hi, I have a list containing the names of all items in a directory. I want to sort it by non-directories first and then directories, with a secondary sort in alph

Re: sorting array full of hash references

2005-06-07 Thread John W. Krahn
Jeremy Kister wrote: I'm stumped on how to sort an array based on a hash refrences's key in each element of my array. this is dumbed down code of what I have: my @array; while(my $row = $sth->fetchrow_arrayref){ my %hash = (id => $row->[0], name => $row->[1]); push(@array, \%hash); } after th

Re: sorting array full of hash references

2005-06-07 Thread Peter Rabbitson
On Tue, Jun 07, 2005 at 10:40:43PM -0400, Jeremy Kister wrote: > I'm stumped on how to sort an array based on a hash refrences's key in > each element of my array. > > this is dumbed down code of what I have: > my @array; > while(my $row = $sth->fetchrow_arrayref){ > my %hash = (id => $row->[0],

RE: sorting array full of hash references

2005-06-07 Thread Charles K. Clarkson
Jeremy Kister wrote: : I'm stumped on how to sort an array based on a hash refrences's : key in each element of my array. : : this is dumbed down code of what I have: : my @array; : while(my $row = $sth->fetchrow_arrayref){ : my %hash = (id => $row->[0], name => $row->

need guidance on encode JSON and sorting

2012-02-05 Thread Rajeev Prasad
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 = $json->get_c

RE:[OT]Sorting (with friendly list netiquette commentary :)

2001-05-11 Thread Paul
--- Jeff Pinyan <[EMAIL PROTECTED]> wrote: > >> @new = sort { > >> my($A) = $a =~ /\@([^:]+)/; > >> my($B) = $b =~ /\@([^:]+)/; > >> return $A cmp $B; > >> } @ary; > > That sorting method

Sorting an array by one of it's fields.

2001-06-16 Thread Tirthankar C.P
$dummy[$i][1] = $data{$key}[$i][1]; } &dumpdummy("Before sorting --", \@dummy); # Now we need to sort the # two columns of @dummy by # column 0 (date). @dummy2 = sort { $a->[0] cmp $b->[0]} @dummy; &dumpdummy("After sorting -

RE: Explaining myself correctly RE: SORTING BY DATE

2001-08-06 Thread Matt Crapo
from the raw values supplied by localtime before you do this. Good luck! Matt -Original Message- From: Daniel Falkenberg [mailto:[EMAIL PROTECTED]] Sent: Monday, August 06, 2001 5:05 PM To: Beginners (E-mail) Subject: Explaining myself correctly RE: SORTING BY DATE List, Please accept my sic

Help with end-time start-time sorting problem

2003-01-09 Thread Scott, Deborah
I have a txt data file that has several fields. Two of the fields are start time and end time (listed in epoch time). I need to write a perl program that finds (and prints) events that occur between midnight "last night" and "midnight tonight." First problem: The date for midnight "last night" a

Sorting Hash of arrays by how many elements

2003-02-03 Thread Paul Kraus
This is straight from the camel pg 277. Unless I misunderstand this then the items with 3 elements should be at the top not in the middle. What am I doing wrong? Can someone break down what the sort statement in this situation is doing. References are still confusing the hell out of me. My code

Re: Sorting files by date (contained in file)

2002-07-08 Thread Shannon Murdoch
Solved 10 minutes later by using: @list = sort { $filelisthash{$b} <=> $filelisthash{$a} } keys %filelisthash; Instead of: foreach $file_num (sort { $a cmp $b } keys %filelisthash) { push(@list,$file_num); } Thanks anyway!! Hope someone finds this helpful... On 8/7/02 9:17 PM, in article

Re: Sorting files by date (contained in file)

2002-07-09 Thread John W. Krahn
Shannon Murdoch wrote: > > Hi all, Hello, > I have a list of 40 or so files that need to be sorted into an array by > article date (found in first line of each file in the form DD-MM-). > I can't figure out how to go about it successfully... Can anyone help me out > please?? > > Thanks in

RE: sorting data (more than one scalar involved)

2002-09-26 Thread Nikola Janceski
hes don't keep any specific order... only arrays do. > -Original Message- > From: Steveo [mailto:[EMAIL PROTECTED]] > Sent: Thursday, September 26, 2002 8:48 AM > To: [EMAIL PROTECTED] > Subject: sorting data (more than one scalar involved) > > > I understa

Re: sorting data (more than one scalar involved)

2002-09-26 Thread John W. Krahn
PA > > CS 5 2 950250 > DOD 4 3 700 400 > HL 0 7 300 1000 > > I can open and close the ascii text file. Whats an approach for going > about sorting this data? Something like this should work: open FILE, 'somefile'

Re: sorting a hash by using a function

2002-11-03 Thread John W. Krahn
Roiy Zysman wrote: > > Hi All, Hello, > How can i get the hash reference when i use a function to sort that hash. > e.g. i want to sort the hash according to is values > I can do something like this > sort {$hash{$a} cmp $hash{$b}} (keys %hash); > but i want to sort it by using a call to a funct

Need help sorting by specific fields in file.

2004-02-02 Thread Dennis G. Wicks
Greetings; I have a file that I need to sort and currently I am just sorting it by @datalist = sort(@datalist); but it will eventually have many more records and many of them may be quite large, but I only need to sort on the first six characters which would be faster. Wouldn't i

Reading File & grep according item 5 and sorting

2004-02-25 Thread Bjorn Van Blanckenberg
let say that the file contains these items (every item is seperated with a tab) one title state name testing number two title2 state2 name2 final number2 one title3 state3 name3 pre number3 four title4 state4 name4 tesing2 number4 six title5 state5 name5 t

Re: avoid repitive code while sorting hash arrays

2003-09-19 Thread Rob Dixon
}, > 'goofy' => { > 'uname' => 'goofy', > 'uid' => 515, > 'gid' => 515 > }, > ); > > Now I

Re: avoid repitive code while sorting hash arrays

2003-09-19 Thread Chuck Fox
}, 'goofy' => { 'uname' => 'goofy', 'uid' => 515, 'gid' => 515 }, ); Now I want to sort on e

Re: avoid repitive code while sorting hash arrays

2003-09-19 Thread Ramprasad A Padmanabhan
y' => { 'uname' => 'goofy', 'uid' => 515, 'gid' => 515 }, ); Now I want to sort on either of the fields 'uname' 'uid' 'gid' and ascending or

Re: avoid repitive code while sorting hash arrays

2003-09-19 Thread Rob Dixon
Ramprasad wrote: > > Rob Dixon wrote: > > > > > > Will this do? > > > > sort { > > my ($va, $vb) = map $$hash{$_}{$sortkey}, $direction eq 'a' ? ($a, $b) : ($b, > > $a); > > $sortkey eq 'uname' ? $va cmp $vb : $va <=> $vb; > > } keys %$hash; > > > > Cheers, > > > > Rob > > > > > > Gr8 Now the

Re: Sorting an array based on hash values

2002-06-20 Thread Jeff 'japhy' Pinyan
On Jun 20, Kevin Old said: >I have a hash with the key being the field name and the value being the >order in which the field is to be displayed.like below: > >%order = ( > DATE => '1', > CPP => '2', > ESN => '3', > BTS => '4' > ); > >I'm receiving an array t

Re: hash containing a hash, sorting keys help

2007-05-05 Thread yaron
) Asia/Jerusalem שבת 5 מאי 2007 Subject: hash containing a hash, sorting keys help I cannot get the syntax right for child lookup, Data::Dumper confirms that I have the structure as I expect (logic may be totally wrong though). I going to do a webpage pstree command. foreach my $chil

Re: hash containing a hash, sorting keys help

2007-05-05 Thread Rob Dixon
Ken Foskey wrote: I cannot get the syntax right for child lookup, Data::Dumper confirms that I have the structure as I expect (logic may be totally wrong though). I going to do a webpage pstree command. foreach my $child (sort keys( $parent{$pid} )) { dump_process( $child ); }

Re: hash containing a hash, sorting keys help

2007-05-05 Thread Tom Phoenix
On 5/5/07, Ken Foskey <[EMAIL PROTECTED]> wrote: foreach my $child (sort keys( $parent{$pid} )) { dump_process( $child ); } Type of arg 1 to keys must be hash (not hash element) at ./visualise.cgi line 46, near "} )" That's saying that you're giving the keys() operator a hash

Re: hash containing a hash, sorting keys help

2007-05-05 Thread Ken Foskey
On Sat, 2007-05-05 at 07:19 -0700, Tom Phoenix wrote: > On 5/5/07, Ken Foskey <[EMAIL PROTECTED]> wrote: > > > foreach my $child (sort keys( $parent{$pid} )) { > > dump_process( $child ); > > } > > > > Type of arg 1 to keys must be hash (not hash element) at ./visualise.cgi > > lin

Need help with sorting on perl template toolkit

2005-09-11 Thread Anish Kumar K
Hi I needed the help as how to sort descending in a hash [%FOREACH keyValue = wordCount.nsort(wordCount.$keyValue)%] [% keyValue %] [% wordCount.$keyValue %] [%END%] This is sorting in ASCENFDING order. I tried out giving - , NOT ASC everything.nothing working. Please

Re: need guidance on encode JSON and sorting

2012-02-05 Thread Rajeev Prasad
Prasad To: perl list 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 to display valu

Re: need guidance on encode JSON and sorting

2012-02-05 Thread Rajeev Prasad
d e.g.: 2012-01-20 22:24:36   value is some text - Original Message - From: Rajeev Prasad To: perl list 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->new;     $json

Re: need guidance on encode JSON and sorting

2012-02-06 Thread Igor Dovgiy
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 l

Sorting a hash by value, and displaying the key

2001-05-31 Thread David Michael
Hello, I have a hash that needs to be displayed in a certain order. I tried foreach $key (sort (keys %HASH)) { print $key; } that sorts alphabetically. I need it in the order it was inserted, so I made the value a number that increased for each key. I need to sort by

Re: Sorting an array by one of it's fields.

2001-06-16 Thread Jos I. Boumans
gt; Folks, > # How do I sort an array by one of it's fields? > > # @dummy before sorting has this: > > 1996013100:00:00MAAA > 281100:00:00MA- > 1997063000:00:00MAAA > 1998122200:00:00MAA >

Re: Sorting an array by one of it's fields.

2001-06-16 Thread Tirthankar C.P
3 1 8 3 ); And if I wanted to sort on the 3rd column. Then I could write: @sorted = sort { $a->[2] <=> $b->[2] } @arr; # or 'cmp' if the sorting is to be lexical. This should've worked. But why do I get a warning: Use of uninitialized value at ./mk2_ratingch

Re: Sorting an array by one of it's fields.

2001-06-16 Thread Jos I. Boumans
same applies here again. this is the trick used: we dig out that value we want to sort on, make that the key of our hash and go from there let me adres the @arr you presented. ### EXAMPLE 1 ### ### this will NOT eliminate the value we're sorting on from the list ### while ( my @s = s

Re: Sorting an array by one of it's fields.

2001-06-16 Thread Me
> This should've worked. But why do I get a warning: > > Use of uninitialized value at ./mk2_ratingchangedb.pl line 39, chunk 8. Whenever you're dealing with baffling array errors like this, always think of off-by-one. In this case: > 30 for ($i=1; ...) { > 31 $dummy[$i][

Re: Sorting an array by one of it's fields.

2001-06-18 Thread Tirthankar C.P
Thanks a million to Jos Boumans, and Me (whoever that is). Me, thanks for the explanation, and Jos, for your patient and detailed answer. -tir On Sat, 16 Jun 2001, Me wrote: > > This should've worked. But why do I get a warning: > > > > Use of uninitialized value at ./mk2_ratingchangedb.p

RE: Help with end-time start-time sorting problem

2003-01-09 Thread Wagner, David --- Senior Programmer Analyst --- WGO
PROTECTED] Subject: Help with end-time start-time sorting problem I have a txt data file that has several fields. Two of the fields are start time and end time (listed in epoch time). I need to write a perl program that finds (and prints) events that occur between midnight "last night" and

RE: Help with end-time start-time sorting problem

2003-01-09 Thread Scott, Deborah
Here's the txt file. Thanks! -Original Message- From: Wagner, David --- Senior Programmer Analyst --- WGO [mailto:[EMAIL PROTECTED]] Sent: Thursday, January 09, 2003 2:32 PM To: Scott, Deborah; [EMAIL PROTECTED] Subject: RE: Help with end-time start-time sorting problem

Re: Help with end-time start-time sorting problem

2003-01-09 Thread R. Joseph Newton
So what have you treied so far? Although production efficiency may be aided by using prefab cope, the learning process is not. you should probably focus attention to the sections on the time function. You may also want to isolate elements of the localtime return string to check for the curren

RE: Help with end-time start-time sorting problem

2003-01-09 Thread Scott, Deborah
Yes, I think so. THANKS! This is a great fantastic group. Glad I found it. >Have got what you need yet? >Wags ;) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: Help with end-time start-time sorting problem

2003-01-10 Thread John W. Krahn
Deborah Scott wrote: > > I have a txt data file that has several fields. Two of the fields are start > time and end time (listed in epoch time). > > I need to write a perl program that finds (and prints) events that occur > between midnight "last night" and "midnight tonight." > > First problem:

RE: Help with end-time start-time sorting problem

2003-01-09 Thread Bob Showalter
Scott, Deborah wrote: > I have a txt data file that has several fields. Two of the fields are > start time and end time (listed in epoch time). > > I need to write a perl program that finds (and prints) events that > occur between midnight "last night" and "midnight tonight." > > First problem: >

Re: Sorting Hash of arrays by how many elements

2003-02-03 Thread Wiggins d'Anconia
See inline. Paul Kraus wrote: This is straight from the camel pg 277. Unless I misunderstand this then the items with 3 elements should be at the top not in the middle. What am I doing wrong? Can someone break down what the sort statement in this situation is doing. References are still confusi

Re: Sorting Hash of arrays by how many elements

2003-02-03 Thread Jenda Krynicky
From: "Paul Kraus" <[EMAIL PROTECTED]> > This is straight from the camel pg 277. > Unless I misunderstand this then the items with 3 elements should be > at the top not in the middle. What am I doing wrong? > > Can someone break down what the sort statement in this situation is > doing. Referenc

Re: Sorting Hash of arrays by how many elements

2003-02-03 Thread Peter Scott
In article <008301c2cbbd$15c27c40$8afea8c0@pkraus>, [EMAIL PROTECTED] (Paul Kraus) writes: >This is straight from the camel pg 277. >Unless I misunderstand this then the items with 3 elements should be at >the top not in the middle. >What am I doing wrong? > >Can someone break down what the sort

RE: Sorting Hash of arrays by how many elements

2003-02-04 Thread Paul Kraus
DOHT! Ya that would do it wouldn't it. Thanks. -Original Message- From: Jenda Krynicky [mailto:[EMAIL PROTECTED]] Sent: Monday, February 03, 2003 6:16 PM To: Perl Subject: Re: Sorting Hash of arrays by how many elements From: "Paul Kraus" <[EMAIL PROTECTED]> &g

Sorting a hash with keys generated on the fly

2002-11-05 Thread Scott, Joshua
I'd like to know the best/easiest way to sort a hash based on the values of it's keys. Here is a snippet of my code. %somehash=(); foreach (@somearray) { $somehash{$_}++; }; Basically I'm getting a count of unique items in an array and I want to sort by the number of each item. I've

Re: Need help sorting by specific fields in file.

2004-02-02 Thread Michael C. Davis
At 01:49 PM 2/2/04 -0600, Dennis G. Wicks wrote: >I have a file that I need to sort and currently I am just >sorting it by > > @datalist = sort(@datalist); > >but it will eventually have many more records and many of >them may be quite large, but I only need to s

Re: Need help sorting by specific fields in file.

2004-02-02 Thread James Edward Gray II
On Feb 2, 2004, at 1:49 PM, Dennis G. Wicks wrote: Greetings; I have a file that I need to sort and currently I am just sorting it by @datalist = sort(@datalist); Okay, but you're not sorting a file there. You're sorting an array. Maybe that array was loaded from a file,

Re: Need help sorting by specific fields in file.

2004-02-02 Thread Dennis G. Wicks
wrote: > Date: Mon, 2 Feb 2004 14:14:31 -0600 > From: Eric Edwards <[EMAIL PROTECTED]> > To: Dennis G. Wicks <[EMAIL PROTECTED]>, [EMAIL PROTECTED] > Subject: Re: Need help sorting by specific fields in file. > > Dennis, > Not to tell you how to run your business,

Re: Need help sorting by specific fields in file.

2004-02-02 Thread Eric Edwards
Wicks" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Monday, February 02, 2004 1:49 PM Subject: Need help sorting by specific fields in file. > Greetings; > > I have a file that I need to sort and currently I am just > sorting it by > > @datalist = sor

Re: Need help sorting by specific fields in file.

2004-02-02 Thread R. Joseph Newton
"Dennis G. Wicks" wrote: > Greetings; > > I have a file that I need to sort and currently I am just > sorting it by > > @datalist = sort(@datalist); Try this: > @articles = sort {substr($a, 6) + 0 <=> substr($b, 6) + 0} > @files; > > bu

Re: Need help sorting by specific fields in file.

2004-02-02 Thread R. Joseph Newton
"R. Joseph Newton" wrote: Correction inline. Forgot the start param for substr() > "Dennis G. Wicks" wrote: > > > Greetings; > > > > I have a file that I need to sort and currently I am just > > sorting it by > > > > @datalist

Re: Need help sorting by specific fields in file.

2004-02-03 Thread Rob Dixon
R. Joseph Newton wrote: > > "Dennis G. Wicks" wrote: > > > Greetings; > > > > I have a file that I need to sort and currently I am just > > sorting it by > > > > @datalist = sort(@datalist); > > Try this: > > >

Re: Reading File & grep according item 5 and sorting

2004-02-28 Thread R. Joseph Newton
Bjorn Van Blanckenberg wrote: > let say that the file contains these items (every item is seperated > with a tab) > ... > > one title3 state3 name3 pre number3 > dip title6 state6 name6 pre2 number6 > So what changes have you made in the code to reflect this diffeence in speci

Re: Reading File & grep according item 5 and sorting

2004-03-02 Thread Bjorn Van Blanckenberg
$b->[5] } map { [ $_ , (split /\t/) ] } @fields; foreach (@sorted){ @bits = split; print "\n" if ($bits[4] ne $lastbit); print "$_\n"; $lastbit=$bits[4]; } this is what I have know but al it does is sorting according item 5 but want it to look in

Re: Reading File & grep according item 5 and sorting

2004-03-02 Thread John W. Krahn
Bjorn Van Blanckenberg wrote: > > On 28-feb-04, at 20:32, R. Joseph Newton wrote: > > > Bjorn Van Blanckenberg wrote: > > > >> let say that the file contains these items (every item is seperated > >> with a tab) > >> > >> one title3 state3 name3 pre number3 > >> dip title6 state6 na

Re: Reading File & grep according item 5 and sorting

2004-03-03 Thread R. Joseph Newton
print "\n" if ($bits[4] ne $lastbit); > print "$_\n"; > $lastbit=$bits[4]; > } > > this is what I have know Do you mind explaining a little about how the code you have so far accomplishes its task. It looks very similar to the example code pos

Re: Reading File & grep according item 5 and sorting

2004-03-04 Thread Bjorn Van Blanckenberg
$lastbit=$bits[4]; } this is what I have know Do you mind explaining a little about how the code you have so far accomplishes its task. It looks very similar to the example code posted on this thread. If I am not mistaken, the code was posted to encourage you to understand how those operati

<    1   2   3   4   5   6   7   8   >