Re: hash of arrays sorting

2012-08-23 Thread Salvador Fandino
$type, ref(code): " . ref($code); +next TEST; +} +} +} +my $sub = eval "sub { $init (" . join(", ", @code) . ") }"; + my $sorter = Sort::Key::multi

Warnings when sorting by hashref

2017-04-11 Thread Mike Martin
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)

Re: Sorting a Two Dimensional Array

2001-05-16 Thread Paul Johnson
On Wed, May 16, 2001 at 10:05:14AM -0700, Matt Noel wrote: > I have a simple two-dimensional array, call it @Weights. I think of the > first index as being the Row index and the second being the Column > index. Normally I'd access an entry thus: > > $ItemWeight = $Weights[$row][$col]; > > I

Re: Sorting a Two Dimensional Array

2001-05-16 Thread Paul
this is a 2D array, the elements of the first dimension are references to the second-dimensional sub-arrays. Thus, @{$a} is the entire sub array, and $a->[0] means "give me element zero of the array poited to by $a". Paul is sorting the first dimension elements by the values in the secon

Re: Sorting a Two Dimensional Array

2001-05-16 Thread Jeff Pinyan
On May 16, Paul said: >"or" also short circuits, and some consider it more readable, but it >(and the "and" operator) always return(s) a boolean value, while || >(and &&) return the value of the first true expression. > > $a or $b # returns 1 if either has a non-false value, else '' > $a || $b

Re: Sorting a Two Dimensional Array

2001-05-16 Thread Paul
For a variable number of second-dimension elements, try: my @sorted = sort { my($ndx,$ret) = (0,0); while(defined($a->[$ndx]) and defined($b->[$ndx])) { last if $ret = ($a->[$ndx] <=> $b->[$ndx++]); } $ret; } @Weights; This keeps comparing elements fro

Re: Sorting a Two Dimensional Array

2001-05-16 Thread Paul
--- Jeff Pinyan <[EMAIL PROTECTED]> wrote: > On May 16, Paul said: > > >"or" also short circuits, and some consider it more readable, but it > >(and the "and" operator) always return(s) a boolean value, while || > >(and &&) return the value of the first true expression. > > > > $a or $b # retur

Re: Sorting a Two Dimensional Array

2001-05-16 Thread M.W. Koskamp
- Original Message - From: Matt Noel <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, May 16, 2001 7:05 PM Subject: Sorting a Two Dimensional Array (...)> I have a simple two-dimensional array, call it @Weights. I think of the > first index as being the

Re: Counting and sorting an array

2001-05-18 Thread Timothy Kimball
: I would like to sort an array like this : my @pets = {$cat, $dog,$camel,$camel,$camel,$dog} : and then to have it printed out in the order of occurrences : print "I will give you <3> camels, <2> dogs, <1> cat " for the blond one Well, first of all, what you have there isn't really an array.

Re: Counting and sorting an array

2001-05-18 Thread Timothy Kimball
Slight correction: : pushd @petcounts, sprintf "<%d> %s%s", should be push @petcounts, sprintf "<%d> %s%s", -- tdk

sorting an id like a.12.34

2003-01-06 Thread Konrad Foerstner
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 with such big array. I hope someone c

sorting an id like a.12.34

2003-01-07 Thread Konrad Foerstner
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 with such big array. I hope someone c

Sorting a 2dim array / Spreadsheet::WriteExcel

2003-01-30 Thread Paul Kraus
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; while (){ chomp; push (@AoA,[(split

RE: Sorting an Array with classobjects

2003-02-27 Thread Hanson, Rob
TED] Subject: Sorting an Array with classobjects Hello Perlgurus! I have made a small program that creates some instances of a classobject and puts them into an array. I want to sort this array in order of a specific value in the class. I was thinking of something like this but it doesn't work

Array sorting (yet another trains question)

2003-03-29 Thread Rob Richardson
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 references to all of the Train objects for that day. I want to sort those train

sorting a hash - multiple key fields

2002-09-17 Thread Jeff AA
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 }, } I want to sort first on taste and then

RE: sorting Numeric OR Character data

2002-11-18 Thread Wagner, David --- Senior Programmer Analyst --- WGO
1: 10 2: 15 10: 5 If you want to see the data, then you would need to explain what you want. Wags ;) -Original Message- From: Balint, Jess [mailto:[EMAIL PROTECTED]] Sent: Monday, November 18, 2002 08:07 To: '[EMAIL PROTECTED]' Subject: sorting Numeric OR Character data

RE: sorting Numeric OR Character data

2002-11-18 Thread Balint, Jess
> If you want to see the data, then you would need to explain > what you want. > Sorry if I was not clear. I would like to know if there is a block equivalent to { $a <=> $b } AND { $a cmp $b } at the same time. If I use the cmp style, my numbers get sort asciibetically and if I use the <=> I ca

RE: sorting Numeric OR Character data

2002-11-18 Thread Wagner, David --- Senior Programmer Analyst --- WGO
- From: Balint, Jess [mailto:[EMAIL PROTECTED]] Sent: Monday, November 18, 2002 12:38 To: 'Wagner, David --- Senior Programmer Analyst --- WGO' Cc: '[EMAIL PROTECTED]' Subject: RE: sorting Numeric OR Character data > If you want to see the data, then you would need to e

RE: Flatfile database sorting in Perl

2002-11-18 Thread Wagner, David --- Senior Programmer Analyst --- WGO
648: 22,bananas,20021118-1648 20021118-1725: 16,apples,20021118-1725 20021118-1921: 4,grapes,20021118-1921 Wags ;) -Original Message----- From: Gavin Laking [mailto:[EMAIL PROTECTED]] Sent: Monday, November 18, 2002 13:53 To: [EMAIL PROTECTED] Subject: Flatfile database sorting in Perl

Re: Flatfile database sorting in Perl

2002-11-18 Thread John W. Krahn
Gavin Laking wrote: > > One of my scripts uses a home-brewed flatfile database to store > information, and I've run up against a problem when I wish to sort > columns of data. > > An example of the database file: > (items,fruit,date) > > 16,apples,20021118-1725 > 22,bananas,20021118-1648 > 4,gra

sorting hash list for CGI Form

2004-03-09 Thread Scott Taylor
Hello all, 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) while( my($id, $desc) = $sth->fetchrow ) { $SrcIDs{$id} = $desc; } $sth-

Re: sorting AoA [was the subject]

2004-03-27 Thread R. Joseph Newton
WC -Sx- Jones wrote: > John W. Krahn wrote: > >>replying) so James can take ownership of those parts of > >>this thread. > > > > > > Not under most country's copyright laws he can't. :-( > > LOL :) > > I'd like to see that erroneous verbage - as words, > expressed as thoughts and ideas in the di

Re: Sorting an array of hashes

2004-08-05 Thread Gunnar Hjalmarsson
Chris Mortimore wrote: I want to sort an AoH. Not each hash by its keys, but the array by the value of one of the keys in each hash. The value of one of the keys? If you don't know *which* key in respective hash, this appears to be pretty tricky... -- Gunnar Hjalmarsson Email: http://www.gunnar.cc

RE: Sorting an array of hashes

2004-08-05 Thread Chris Mortimore
Chris Mortimore wrote: > I want to sort an AoH. Not each hash by its keys, but the array by > the value of one of the keys in each hash. The value of one of the keys? If you don't know *which* key in respective hash, this appears to be pretty tricky... -- Gunnar Hjalmarsson Email: http://www.g

RE: Sorting an array of hashes

2004-08-05 Thread Chris Devers
On Thu, 5 Aug 2004, Chris Mortimore wrote: Gunnar Hjalmarsson wrote: > Chris Mortimore wrote: >> I want to sort an AoH. Not each hash by its keys, but the array by >> the value of one of the keys in each hash. > > The value of one of the keys? If you don't know *which* key in > respective hash, th

RE: Sorting an array of hashes

2004-08-05 Thread Moon, John
-Original Message- From: Chris Mortimore [mailto:[EMAIL PROTECTED] Sent: Thursday, August 05, 2004 5:19 PM To: [EMAIL PROTECTED] Subject: Sorting an array of hashes I want to sort an AoH. Not each hash by its keys, but the array by the value of one of the keys in each hash. I know how

Re: Sorting an array of hashes

2004-08-05 Thread Randy W. Sims
On 8/5/2004 5:18 PM, Chris Mortimore wrote: I want to sort an AoH. Not each hash by its keys, but the array by the value of one of the keys in each hash. I know how to sort a simple array. I know how to sort a hash by the keys. Could someone kindly point me to the documentation on sorting arrays

Re: Sorting an array of hashes

2004-08-05 Thread Gunnar Hjalmarsson
Chris Mortimore wrote: Gunnar Hjalmarsson wrote: Chris Mortimore wrote: I want to sort an AoH. Not each hash by its keys, but the array by the value of one of the keys in each hash. The value of one of the keys? If you don't know *which* key in respective hash, this appears to be pretty tricky...

RE: Sorting an array of hashes

2004-08-06 Thread Chris Mortimore
-Original Message- From: Chris Mortimore [mailto:[EMAIL PROTECTED] Sent: Thursday, August 05, 2004 5:19 PM To: [EMAIL PROTECTED] Subject: Sorting an array of hashes I want to sort an AoH. Not each hash by its keys, but the array by the value of one of the keys in each hash. I know how

File sorting by a specific date

2003-10-17 Thread Paul Harwood
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; #Right here, I am wondering if there is a

Re: DB_File and auto sorting DB's

2002-02-18 Thread Jenda Krynicky
t acceptable to use db without "use DB_File"; > or if I do use it, can I always count on the automatic > sorting? The docs seem to say that hashes will come back > unsorted without a sort routine. > > >

Re: sorting with complicated data structure

2002-02-24 Thread Tanton Gibbs
ent: Sunday, February 24, 2002 12:27 PM Subject: sorting with complicated data structure > Hi all > >I am attempting to sort the following data. But I cannot get it to work. > Frankly i am not even sure I am allowed to do this in perl. Nonetheless I > hope anyone can give me som

Re: Sorting a hash table - Advanced;)

2002-02-28 Thread Tor Hildrum
On 27/2/02 17:33, "Steven M. Klass" <[EMAIL PROTECTED]> wrote: > Hi all, > > ok here is the fundamental code > > print "\n\n**Summary**\n"; > foreach my $key (keys %runset){ > printf ( "%-20s %-20s\n",$key, $runset{$key}); > } > > Now I want to sort this hash for example > print "\n\n**Summa

Re: Sorting a hash table - Advanced;)

2002-02-28 Thread Tor Hildrum
ething like that? Answering my own post.. After reading this, I realized that you where probably talking about sorting the specific keys. Since I'm not really that advanced, it gets bloated fast. My $counter = "0": print "\n\n**Summary**\n"; foreach my $key (keys %runset){

Re: Sorting a hash table - Advanced;)

2002-02-28 Thread Vitali
"Tor Hildrum" <[EMAIL PROTECTED]> To: "Perl" <[EMAIL PROTECTED]>; "Steven M. Klass" <[EMAIL PROTECTED]> Sent: Thursday, February 28, 2002 3:01 PM Subject: Re: Sorting a hash table - Advanced;) > On 27/2/02 17:33, "Steven M. Klass"

Re: sorting a hash by value.

2002-06-23 Thread Shawn
Hello Pat, You can do it like so: my %hash; foreach(sort {$hash{$a} <=> $hash{$b} } keys %hash) { } Shawn - Original Message - From: "Postman Pat" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Monday, June 24, 2002 1:46 AM Subj

Re: sorting a hash by value.

2002-06-24 Thread Nigel Peck
Shouldn't that be "values %hash" for sorting the values (see below), also be aware that a hash has no order like an array so you just have to do what you want while in the foreach loop (or stick them into an array). my %hash; foreach(sort {$hash{$a} <=> $ha

Re: sorting a hash by value.

2002-06-24 Thread Shawn
> Shouldn't that be "values %hash" for sorting the values (see below), > also be aware that a hash has no order like an array so you just have to > do what you want while in the foreach loop (or stick them into an > array). > > my %hash; > foreach(sort {$h

Re: sorting a hash by value.

2002-06-24 Thread Shawn
>foreach(sort { $hash{$a} <=> $hash{$b} } values %hash) { > print "$_\n"; >} Err... This will not work... You will be trying to get a hash value based on the value... It's early my %hash=(thumb='122',tom=>'21',muffit=>'48',miss=>'31'); foreach(sort { $hash{$a} <=> $hash{$b} } values %hash

RE: sorting a hash by value.

2002-06-24 Thread Bob Showalter
> -Original Message- > From: Postman Pat [mailto:[EMAIL PROTECTED]] > Sent: Monday, June 24, 2002 2:46 AM > To: [EMAIL PROTECTED] > Subject: sorting a hash by value. > > > Greetings, > I would like to sort a hash by value. The hash values are > numbers. I

Re: sorting a hash by value.

2002-06-24 Thread Nigel Peck
For some stupid reason I was imagining that foreach(sort { $hash{$a} <=> $hash{$b} } keys %hash) { was going to sort by the keys and not the values, overlooking the comparison being based on the value, thanks for pointing it out (now I understand :-) >>> "Shawn" <[EMAIL PROTECTED]> 06/24/02 10

Re: sorting a hash by value.

2002-06-24 Thread Jeff 'japhy' Pinyan
On Jun 24, Postman Pat said: >I would like to sort a hash by value. The hash values are numbers. I would >like to sort this by desceding order. How would I do this? I have searched >and found nothing on it. I have found lots on sorting by key though... Where did you search? A sin

Re: sorting in perl - help me

2002-01-12 Thread John W. Krahn
Sanilkumar wrote: > > Enyone can help me: > > how to do Quicksort , selection sort ,mergesort and > external merge sort in perl that programes are exactly the same way that > programes in C/C++ This book covers sorting in Perl: http://www.oreilly.

Re: sorting in perl - help me

2002-01-14 Thread Jenda Krynicky
From: sanilkumar <[EMAIL PROTECTED]> > Enyone can help me: > >how to do Quicksort , selection sort ,mergesort and > external merge sort in perl that programes are exactly the same way > that programes in C/C++ Well ... exactly the same way you'd do it in C/C++. The algorithms may be im

RE: Sorting an array of hashes

2002-02-06 Thread Nikola Janceski
$item (@sorted){ print $item->{ID}, "\n"; } -Original Message- From: Tomasi, Chuck [mailto:[EMAIL PROTECTED]] Sent: Wednesday, February 06, 2002 2:18 PM To: '[EMAIL PROTECTED]' Subject: Sorting an array of hashes Does anyone have any clever ideas

Re: Sorting an array of hashes

2002-02-06 Thread Chas Owens
On Wed, 2002-02-06 at 14:17, Tomasi, Chuck wrote: > Does anyone have any clever ideas for sorting an array of hashes based on > a key such as an ID number? > > Example: > > @AoH = ( > { ID => 10101, UserID => 1041, Status => 2 }, > { ID =>

Re: Sorting an array of hashes

2002-02-06 Thread Shawn
- Original Message - From: "Tomasi, Chuck" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, February 06, 2002 1:17 PM Subject: Sorting an array of hashes > Does anyone have any clever ideas for sorting an array of hashes based on > a key such a

Re: Sorting an array of hashes

2002-02-06 Thread Brett W. McCoy
On Wed, 6 Feb 2002, Tomasi, Chuck wrote: > Does anyone have any clever ideas for sorting an array of hashes based on > a key such as an ID number? > > Example: > > @AoH = ( > { ID => 10101, UserID => 1041, Status => 2 }, > { ID =>

RE: Sorting an array of hashes

2002-02-06 Thread Tomasi, Chuck
06, 2002 1:28 PM > To: 'Tomasi, Chuck'; '[EMAIL PROTECTED]' > Subject: RE: Sorting an array of hashes > > > @sorted = sort { > $a->{ID} <=> $b->{ID} ## remember that $a and $b > become the element > of the array > ## so if

Re: Strange sorting, need some help

2008-07-20 Thread Rob Dixon
t array to sort > print "@unsortiert"; print "\n"; > > # Print positions of unsorted array (0 to last entry #) > my @pos_unsortiert = (0..$#unsortiert); > print "@pos_unsortiert"; print "\n"; > > # Start sorting > my @pos_sortiert =

AW: Strange sorting, need some help

2008-07-21 Thread Tobias Eichner
@rob: Thank you for your hints :-) __ Gesendet von Yahoo! Mail. Dem pfiffigeren Posteingang. http://de.overview.mail.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://lear

Re: Strange sorting, need some help

2008-07-21 Thread Amit Saxena
; use strict; use warnings; use diagnostics; > > > > # Array to sort > > my @unsortiert = qw(Z A z a 19 91); > > > > # Print array to sort > > print "@unsortiert"; print "\n"; > > > > # Print positions of unsorted array (0 to last en

Re: Strange sorting, need some help

2008-07-21 Thread Gunnar Hjalmarsson
with the cmp operator. Sorting numbers as strings causes them to be sorted in dictionary order, which is different from numeric order if the numbers have the same number of digits. So 2 is greater than 11 in the same way that 'B'is greater than 'AA'. That means you want

Re: sorting anonymous arrays inside arrays

2009-07-02 Thread Jim Gibson
On 7/2/09 Thu Jul 2, 2009 12:12 PM, "daem0n...@yahoo.com" scribbled: > > Hi, > > If I have a loop that for each run creates > > while (){ >   my $value =~ /^\d/; >   $myhash{$mykey}->{'subkey'} = $value; > } > > > Normally, if I only want to sort $myhash through it's values, I would do > s

Sorting a hash to user needs

2009-07-08 Thread Alexander Müller
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) } (

Re: Pbm in Sorting the hash

2007-09-21 Thread Tom Phoenix
On 9/21/07, sivasakthi <[EMAIL PROTECTED]> wrote: > open(FILE,:/tmp/test.txt/" or die "cant open the file"); You probably meant a quote mark instead of a colon there. > foreach $dname (sort {$noofconns{$b} <=> $noofconns{$a}} %noofconns) It looks as if you want to use the keys() function there,

Re: Pbm in Sorting the hash

2007-09-21 Thread Rob Dixon
sivasakthi wrote: Hi all, I have file like that following, site_name access_time www.google.com14:13:04|14:13:04| 172.16.5.49 14:12:10|14:12:56| 172.16.65.53 14:12:41|14:12:58| 172.16.671.35 14:12:29| from the above file i n

Re: Pbm in Sorting the hash

2007-09-21 Thread Chas. Owens
On 9/21/07, sivasakthi <[EMAIL PROTECTED]> wrote: > Hi all, > > I have file like that following, > > site_name access_time > www.google.com14:13:04|14:13:04| > 172.16.5.49 14:12:10|14:12:56| > 172.16.65.53 14:12:41|14:12:58| > 172.16.671.35

Re: Pbm in Sorting the hash

2007-09-21 Thread John W. Krahn
sivasakthi wrote: Hi all, Hello, I have file like that following, site_name access_time www.google.com14:13:04|14:13:04| 172.16.5.49 14:12:10|14:12:56| 172.16.65.53 14:12:41|14:12:58| 172.16.671.35 14:12:29| from the abov

Re: Pbm in Sorting the hash

2007-09-22 Thread Dr.Ruud
sivasakthi schreef: > Could u help me to solve the pbm??? Try this first: s/\bu\b/you/ s/\bpbm\b/problem/ s/\?{3}/?/ -- Affijn, Ruud "Gewoon is een tijger." -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: Pbm in Sorting the hash

2007-09-23 Thread sivasakthi
On Fri, 2007-09-21 at 12:47 -0400, Chas. Owens wrote: > On 9/21/07, sivasakthi <[EMAIL PROTECTED]> wrote: > > Hi all, > > > > I have file like that following, > > > > site_name access_time > > www.google.com14:13:04|14:13:04| > > 172.16.5.49 14:12:10|14:12

Re: Re: Sorting files by date

2006-05-24 Thread cajun
[EMAIL PROTECTED] wrote: > [EMAIL PROTECTED] wrote: > > I have a rather large group of files (~5000) that I would like to sort > > into directories by date. Initially by year, then perhaps later by > > year/month. > > > > I'm looking at the -M operator, but it seems like that would requ

Re: Conditional sorting across two arrays

2006-12-12 Thread Rob Dixon
Rinku Mahesh wrote: > Hi, > > I've two arrays of same depth (let it be 6) > > 1st Array:- @unique {11 , 23, 44, 66, 900, 1009} 2nd Array:- @occ_count {2, > 77, 22, 2, 77,29} > > Here I'm looking for a sorting mechanism with the following conditions:- > &g

Re: Conditional sorting across two arrays

2006-12-12 Thread Rob Coops
Mahesh <[EMAIL PROTECTED]> wrote: Hi, I've two arrays of same depth (let it be 6) 1st Array:- @unique {11 , 23, 44, 66, 900, 1009} 2nd Array:- @occ_count {2, 77, 22, 2, 77,29} Here I'm looking for a sorting mechanism with the following conditions:- a. Sort 2nd Array in desce

Re: Conditional sorting across two arrays

2006-12-12 Thread Dr.Ruud
s of elements of 2nd array such that sorting the 1st > array should reflect {23,900,1009,44,11,66} Why then are these values not stored in an AoA? (see perldsc) my @x = ( [ 11, 2] , [ 23, 77] , [ 44, 22] , [ 66, 2] , [ 900, 77] , [1009, 29] )

Re: Conditional sorting across two arrays

2006-12-12 Thread Ovid
--- Rob Coops <[EMAIL PROTECTED]> wrote: > Hi Rinku, > > Now I could try and explain this in my own words but I think this > will help you a lot more. > > http://www.unix.org.ua/orelly/perl/advprog/ch02_02.htm > > What you are looking for is a very common thing, your not the first > to bump int

RE: Conditional sorting across two arrays

2006-12-12 Thread Charles K. Clarkson
Rinku Mahesh <mailto:[EMAIL PROTECTED]> wrote: : If the above explaination is confusing I'm looking for a way : where every element of an array can be mapped to corresponding : element of another array and as a whole both the arrays require : a sorting w.r.t. 2nd array. M.J. Do

Re: Conditional sorting across two arrays

2006-12-12 Thread Paul
On Tue, December 12, 2006 6:25 am, Ovid wrote: > --- Rob Coops <[EMAIL PROTECTED]> wrote: > >> Hi Rinku, >> Now I could try and explain this in my own words but I think this will help you a lot more. >> >> What you are looking for is a very common thing, your not the first to bump into this problem

Re: Conditional sorting across two arrays

2006-12-12 Thread Mumia W.
On 12/12/2006 04:00 AM, Rinku Mahesh wrote: Hi, I've two arrays of same depth (let it be 6) 1st Array:- @unique {11 , 23, 44, 66, 900, 1009} 2nd Array:- @occ_count {2, 77, 22, 2, 77,29} Here I'm looking for a sorting mechanism with the following conditions

Re: Sorting an Array of Arrays

2007-03-13 Thread John W. Krahn
Hardly Armchair wrote: > Hello List, Hello, > I have a data structure containing a bunch of strings in different groups: > > $groups = [ > [ > 'SSPDQR', > 'SSPSDR', > 'STSSER', > ], > [ > 'CSANLH', >

Re: Sorting an Array of Arrays

2007-03-13 Thread Mumia W.
On 03/13/2007 07:44 PM, Hardly Armchair wrote: Hello List, I have a data structure containing a bunch of strings in different groups: [...] I want these sorted first alphabetically within the group, and then according to the number of member in the group. [...] This is slightly more compact

Re: Sorting an Array of Arrays

2007-03-14 Thread Randal L. Schwartz
alphabetically within the group, and then >> according to the number of member in the group. >> [...] "Mumia> This is slightly more compact way to do it: "Mumia> @s_groups = map { [ sort { $a cmp $b } @$_ ]; } @$groups; Uh, sort { $a cmp $b } @input is jus

Sorting the items in a directory

2007-04-27 Thread Nigel Peck
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 = $args->{direc

sorting array full of hash references

2005-06-07 Thread Jeremy Kister
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 the while loop, I'm tryin

Re: more hashref within array sorting

2005-08-09 Thread Paul Johnson
On Tue, Aug 09, 2005 at 06:03:18AM -0400, Jeremy Kister wrote: > I've got an array full of hashrefs: > my @a = ( {N => '10.1.2.1'}, > {N => '10.1.9.1'}, > {N => '10.3.5.1'}, > {N => '10.1.1.3'}, > ); > > I want to sort this array, and print. I expect the ou

Re: more hashref within array sorting

2005-08-09 Thread Jeremy Kister
On 8/9/2005 6:26 AM, Paul Johnson wrote: > my @s = map { $_ -> [0] } > sort { $a->[0] <=> $b->[0] || >$a->[1] <=> $b->[1] || >$a->[2] <=> $b->[2] || >$a->[3] <=> $b->[3] } > map { [ $_, split /\./ ] } > map { $_->{N} } @a;

Re: more hashref within array sorting

2005-08-09 Thread Paul Johnson
On Tue, Aug 09, 2005 at 06:53:33AM -0400, Jeremy Kister wrote: > On 8/9/2005 6:26 AM, Paul Johnson wrote: > > my @s = map { $_ -> [0] } > > sort { $a->[0] <=> $b->[0] || > >$a->[1] <=> $b->[1] || > >$a->[2] <=> $b->[2] || > >$a->[3] <=> $b->

Re: more hashref within array sorting

2005-08-09 Thread John W. Krahn
Jeremy Kister wrote: > On 8/9/2005 6:26 AM, Paul Johnson wrote: >>my @s = map { $_ -> [0] } >>sort { $a->[0] <=> $b->[0] || >> $a->[1] <=> $b->[1] || >> $a->[2] <=> $b->[2] || >> $a->[3] <=> $b->[3] } >>map { [ $_, split /\./ ] } >>

Re: more hashref within array sorting

2005-08-09 Thread Jeremy Kister
On 8/9/2005 8:43 AM, John W. Krahn wrote: > Jeremy Kister wrote: >>I've apparently dumbed down my code and question a bit too much: I have >>multiple hashrefs in each element of the array, and I need the resulting >>sorted array to contain all the data in the original array, simply >>sorted by the

Re: more hashref within array sorting

2005-08-09 Thread Jeff 'japhy' Pinyan
On Aug 9, Jeremy Kister said: my @s = map $_->[ 1 ], sort { $a->[ 0 ] cmp $b->[ 0 ] } map [ inet_aton( $_->{ N } ), $_ ], @a; Now to analyze WTF we're doing here :) Paul's answer had a slight typo in it -- he was comparing $a->[0], $a->[1], $a->[2], and $a->[3], wh

Re: more hashref within array sorting

2005-08-09 Thread Paul Johnson
On Tue, Aug 09, 2005 at 05:00:44PM -0400, Jeff 'japhy' Pinyan wrote: > On Aug 9, Jeremy Kister said: > > >>my @s = map $_->[ 1 ], > >>sort { $a->[ 0 ] cmp $b->[ 0 ] } > >>map [ inet_aton( $_->{ N } ), $_ ], > >>@a; > > > >Now to analyze WTF we're doing here :) > > Paul'

RE: Sorting a hash of hashes

2006-02-02 Thread Wagner, David --- Senior Programmer Analyst --- WGO
Scott Palmer wrote: > I am attempting to sort by a field in a hash within a hash and I am > having a hard time finding the right direction. I want the print out > to sort from smallest to largest in size. Any help would be greatly > appreciated. > > Scott > > -

Re: Sorting a hash of hashes

2006-02-03 Thread John W. Krahn
Scott Palmer wrote: > I am attempting to sort by a field in a hash within a hash and I am > having a hard time finding the right direction. I want the print out to > sort from smallest to largest in size. Any help would be greatly > appreciated. > > -- > #!

Re: Sorting an extremely LARGE file

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

Re: Sorting an extremely LARGE file

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

Re: Sorting an extremely LARGE file

2011-08-07 Thread Ramprasad Prasad
On 7 August 2011 21:24, Shawn H Corey 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 respon

Re: Sorting an extremely LARGE file

2011-08-07 Thread Dr.Ruud
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 is

Re: Sorting an extremely LARGE file

2011-08-07 Thread Rajeev Prasad
print $}' > tmp-file   sort   for id in `cat `;do grep $id >> sorted-large-file;done From: Ramprasad Prasad To: Shawn H Corey Cc: Perl Beginners Sent: Sunday, August 7, 2011 11:01 AM Subject: Re: Sorting an extremely LARGE file On 7 August 2011 21:24, Shawn H Corey wrote: >

Re: Sorting an extremely LARGE file

2011-08-07 Thread Paul Johnson
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

Re: Sorting an extremely LARGE file

2011-08-07 Thread shawn wilson
On Aug 7, 2011 1:15 PM, "Paul Johnson" 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 etc

Re: Sorting an extremely LARGE file

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

Re: Sorting an extremely LARGE file

2011-08-07 Thread Rob Dixon
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. Other

Re: Sorting an extremely LARGE file

2011-08-07 Thread shawn wilson
On Sun, Aug 7, 2011 at 15:58, Rob Dixon 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 sorti

Re: Sorting an extremely LARGE file

2011-08-07 Thread Uri Guttman
> "RP" == Rajeev Prasad 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 sorted file

Re: Sorting an extremely LARGE file

2011-08-07 Thread Ramprasad Prasad
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 table.

Re: Sorting an extremely LARGE file

2011-08-07 Thread Kenneth Wolcott
On Sun, Aug 7, 2011 at 22:10, Ramprasad Prasad 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 > need a overhaul be

Re: Sorting an extremely LARGE file

2011-08-08 Thread Paul Johnson
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

Re: Sorting an extremely LARGE file

2011-08-08 Thread shawn wilson
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 > minutes and in the end produces no output. > I had a smaller file and 32g to play with on a dual quad core (dl320). Sort just c

Re: Sorting an extremely LARGE file

2011-08-08 Thread Paul Johnson
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 > > minutes and in the end produces no output. > > I had a

<    1   2   3   4   5   6   7   8   >