Re: Sorting

2001-05-10 Thread Paul
--- Nic LAWRENCE <[EMAIL PROTECTED]> wrote: > Can anybody suggest the most efficient method to do the following... > > I have an array of email aliases like the following: > [EMAIL PROTECTED]: sys > [EMAIL PROTECTED]: coookiecom > [EMAIL PROTECTED]:

RE: Sorting

2001-05-10 Thread Peter Cornelius
I don't know if this is "correct" but I would use sort and pass in a custom compare function. @sortedArray = sort { compareDomains() } @unsortedArray; sub compareDomains { my ($userA, $domainA) = split /@/, $a; my ($userB, $domainB) = split /@/, $a; return ($domainA cmp

RE: Sorting

2001-05-10 Thread Nic LAWRENCE
WRENCE; 'Beginner Perl' > Subject: Re: Sorting > > > > --- Nic LAWRENCE <[EMAIL PROTECTED]> wrote: > > Can anybody suggest the most efficient method to do the following... > > > > I have an array of email aliases like the following: >

RE: Sorting

2001-05-10 Thread Jeff Pinyan
On May 10, Nic LAWRENCE said: >> > Can anybody suggest the most efficient method to do the following... >> > >> > I have an array of email aliases like the following: >> > [EMAIL PROTECTED]: sys >> > [EMAIL PROTECTED]: coookiecom >> > [EMAIL PROTECTED]:

RE: Sorting

2001-05-10 Thread Jeff Pinyan
On May 10, Jeff Pinyan said: > { >my %cache; >@new = sort { > ($cache{$a}) = $a =~ /\@([^:]+)/ if not exists $cache{$a}; > ($cache{$b}) = $b =~ /\@([^:]+)/ if not exists $cache{$b}; > $cache{$a} cmp $cache{$b} >} @orig; } -- Jeff "japhy" Pinyan [EMAIL PROTEC

RE: Sorting

2001-05-10 Thread Peter Scott
At 05:55 PM 5/10/01 -0400, Jeff Pinyan wrote: >That sorting method does a lot of work -- that is, it does things more >than once. I suggest you use a schwarztian transform, or the Orcish >manuever, to increase speed. I'd like our beginners to take home the message that you shouldn't optimize fo

RE: Sorting

2001-05-10 Thread Jeff Pinyan
On May 10, Peter Scott said: >At 05:55 PM 5/10/01 -0400, Jeff Pinyan wrote: >>That sorting method does a lot of work -- that is, it does things more >>than once. I suggest you use a schwarztian transform, or the Orcish >>manuever, to increase speed. > >I'd like our beginners to take home the mes

Re: Sorting

2001-05-10 Thread Me
> >I'd like our beginners to take home the message that you shouldn't optimize > >for performance until it's clear you need to. Otherwise you're just > >wasting programmer time. Premature optimization is the root of, etc. > > While I agree, it's a good idea to know why things are slow, and why >

Re: Sorting

2001-06-19 Thread Me
> Could someone tell me how to sort these files? > > As you can see they are already sorted in perl, but the problem is .7 is > suppose to be before 10. > > to get this sort i used > @list_of_files=sort @list_of_files; > > sorted EMX-1.15.0.17.37-EMX-1.15.0.17.36.dlcwrap > sorted EMX-1.15.1.42.10-

Re: Sorting

2002-04-29 Thread John W. Krahn
Imtiaz Ahmad wrote: > > Hi- Hello, > Lets say if we have an ARRAY @array_1 with following values: > > 31472 468X60 1.49 > 31473 468X60 2.18 > 31488 180X60 1.39 > 31476 468X60 1.58 > 33472 120X60 2.49 > 32473 468X60 4.38 > > #

RE: Sorting

2002-04-30 Thread Jackson, Harry
>-Original Message- >From: Imtiaz ahmad [mailto:[EMAIL PROTECTED]] > > >And I want to sort @array_1 by szname which is the second column. >How do I do it so that it includes all the column when sorting. > > What I hav

RE: Sorting

2002-04-30 Thread Jackson, Harry
>-Original Message- >From: Jackson, Harry >Sent: 30 April 2002 09:14 >To: [EMAIL PROTECTED] >Subject: RE: Sorting > > > > >>-Original Message- >>From: Imtiaz ahmad [mailto:[EMAIL PROTECTED]] >> >>#

Re: Sorting

2002-04-30 Thread Teresa Raymond
John, Could you please comment/explain the following lines please? >my @sorted = map { (split/\0/)[1] } > sort > map { "@{[(split)[1,0,2]]}\0$_" } > @array; >John >-- >use Perl; >program >fulfillment > >-- >To unsubscribe, e-mail: [EMAIL PROTECTED] >For ad

RE: Sorting

2002-04-30 Thread David Gray
> John, > Could you please comment/explain the following lines please? > >my @sorted = map { (split/\0/)[1] } > > sort > > map { "@{[(split)[1,0,2]]}\0$_" } > > @array; It's fun trying to figure out what the heck John's code does :) Split each element of @a

RE: Sorting

2001-11-04 Thread Wagner-David
Uncertain where you want to go: To get a sorted set from a hash, then do: foreach my $MyId (sort keys %recipient) # now sorted by recipient } Is this what you are after? Wags ;) -Original Message- From: David Stavert [mailto:[EMAIL

RE: Sorting

2001-11-04 Thread David Stavert
-- > From: Wagner-David [mailto:[EMAIL PROTECTED]] > Sent: Sunday, November 04, 2001 1:56 PM > To: 'David Stavert'; [EMAIL PROTECTED] > Subject: RE: Sorting > > > Uncertain where you want to go: > > To get a sorted set from a hash, then do: >

Re: Sorting

2001-11-04 Thread Andrea Holstein
David Stavert schrieb: > > The results of my foreach loop looks like > > <[EMAIL PROTECTED]><[EMAIL PROTECTED]> > <[EMAIL PROTECTED]><[EMAIL PROTECTED]> > <[EMAIL PROTECTED]><[EMAIL PROTECTED]> > <[EMAIL PROTECTED]> > <[EMAIL PROTECTED]><[EMAIL PROTECTED]> > <[EMAIL PROTECTED]><[EMAIL PROTECTED]

Re: Sorting!

2008-08-02 Thread Mr. Shawn H. Corey
On Sun, 2008-08-03 at 01:53 +0530, Gunwant Singh wrote: > Hi all, > > I really appreciate all you guys there for the help you've provided to > me in the past. > So here I am again with a Question. > > I have a file with the following entries: > > 1:17 > 4:3 > 4:11 > 4:13 > 11:16 > 12:10 > 13:2

Re: Sorting!

2008-08-02 Thread Rob Dixon
Gunwant Singh wrote: > Hi all, > > I really appreciate all you guys there for the help you've provided to > me in the past. > So here I am again with a Question. > > I have a file with the following entries: > > 1:17 > 4:3 > 4:11 > 4:13 > 11:16 > 12:10 > 13:2 > 19:5 > 20:7 > 26:12 > 28:4 > 33:1

Re: Sorting!

2008-08-03 Thread Gunwant Singh
Rob Dixon wrote: Gunwant Singh wrote: Hi all, I really appreciate all you guys there for the help you've provided to me in the past. So here I am again with a Question. I have a file with the following entries: 1:17 4:3 4:11 4:13 11:16 12:10 13:2 19:5 20:7 26:12 28:4 33:15 33:17 35:9 36:

Re: Sorting!

2008-08-03 Thread Rob Dixon
Gunwant Singh wrote: > Rob Dixon wrote: >> >> my @sorted = sort { >> my @a = split /:/, $a; >> my @b = split /:/, $b; >> $a[1] <=> $b[1]; >> } @list; >> >> print "$_\n" foreach @sorted; > > I got what your code says.Thanks a lot!! > Can you tell me what is $a[1] <=> $b[1] doing for me? It co

Re: sorting

2006-03-19 Thread Randal L. Schwartz
> ""Ash" == "Ash Varma" <[EMAIL PROTECTED]> writes: "Ash> Hi.. "Ash> I have: "Ash> $code[0][0] = "AAA" "Ash> $code[0][1] = "19.5" "Ash> $code[1][0] = "AAD" "Ash> $code[1][1] = "20.0" "Ash> $code[2][0] = "ZZZ" "Ash> $code[2][1] = "10.7" "Ash> $code[3][0] = "XXA" "Ash> $code[3][1] = "5.9" "Ash>

Re: sorting

2006-03-19 Thread Christer Ekholm
"Ash Varma" <[EMAIL PROTECTED]> writes: > Hi.. > > I have: > > $code[0][0] = "AAA" > $code[0][1] = "19.5" > $code[1][0] = "AAD" > $code[1][1] = "20.0" > $code[2][0] = "ZZZ" > $code[2][1] = "10.7" > $code[3][0] = "XXA" > $code[3][1] = "5.9" > $code[4][0] = "YXA" > $code[4][1] = "27.1" > $code[5][0]

Re: sorting

2006-03-19 Thread Ash Varma
sorry for an incomplete question, but this is exactly what I was after.. :) Thanks On 3/20/06, Christer Ekholm <[EMAIL PROTECTED]> wrote: > > "Ash Varma" <[EMAIL PROTECTED]> writes: > > > Hi.. > > > > I have: > > > > $code[0][0] = "AAA" > > $code[0][1] = "19.5" > > $code[1][0] = "AAD" > > $code[

Re: sorting?

2006-05-29 Thread Wijaya Edward
- Original Message - From: Beast <[EMAIL PROTECTED]> Date: Wednesday, May 31, 2006 1:59 pm Subject: sorting? > Hi, > > I have some rather big chunk of data, returned from ldap server. > The > format is simple: > "Displa name" <[EMAIL PROTECTED]> > > Simply displying data "as is" is

Re: sorting?

2006-05-29 Thread Sumo Wrestler (or just ate too much)
Beast wrote: Hi, I have some rather big chunk of data, returned from ldap server. The format is simple: "Displa name" <[EMAIL PROTECTED]> Simply displying data "as is" is simple, but how do I sorted by "display name"? pls note that "display name" contains space and might not unique so I ca

Re: sorting?

2006-05-30 Thread D. Bolliger
Beast am Mittwoch, 31. Mai 2006 07.59: > Hi, Hi > I have some rather big chunk of data, returned How 'returned'? > from ldap server. The > format is simple: > "Displa name" <[EMAIL PROTECTED]> > > Simply displying in the sense of printing to STDOUT? > data "as is" is simple, but how do I s

Re: sorting?

2006-05-30 Thread Chandru
Hi $ cat data "chandru k" <[EMAIL PROTECTED]> "prg " <[EMAIL PROTECTED]> "chandru k" <[EMAIL PROTECTED]> $ cat script.pl #!/usr/bin/perl while(<>) { chomp; ($mail,$name)=split(/\t/,reverse($_),2); $ha{reverse($mail)}=reverse($name); } foreach $k(sort values(%ha)) {

Re: sorting?

2006-05-30 Thread Beast
Beast wrote: Hi, I have some rather big chunk of data, returned from ldap server. The format is simple: "Displa name" <[EMAIL PROTECTED]> Simply displying data "as is" is simple, but how do I sorted by "display name"? pls note that "display name" contains space and might not unique so I ca

Re: sorting?

2006-05-30 Thread D. Bolliger
Beast am Mittwoch, 31. Mai 2006 12.06: > Beast wrote: > > Hi, > > > > I have some rather big chunk of data, returned from ldap server. The > > format is simple: > > "Displa name" <[EMAIL PROTECTED]> > > > > Simply displying data "as is" is simple, but how do I sorted by > > "display name"? > > pls

RE: sorting?

2006-05-30 Thread Charles K. Clarkson
Caution: Untested code follows. I don't have an LDAP server to test this, but after reading the rather convoluted docs it looks like there is a sorted() method to help shorten your code a bit. The "attrs" argument in the search() method may define the order in which attrs are returned by

RE: sorting thoughts

2003-01-29 Thread Ed Christian
Undoubtedly not the best way of doing this, but here's one stab at it. This assumes you have your data stored in an array as a single string, rather than having an array of array pointers. my @array = ('fred:lucy:24', 'john:jane:10', 'frank:mary:5'); @array = sort { my @a_vals = split (':', $a);

RE: sorting thoughts

2003-01-29 Thread Wagner, David --- Senior Programmer Analyst --- WGO
[EMAIL PROTECTED] wrote: > Hi > > just about to embark on a sorting routine, and I thought before I > spend ages(at my ability) I would see what thoughts you guys have on > this. > > I have an array, each line contains fields seperated by ":" > I want to sort the array numerically ascending by

Re: sorting thoughts

2003-01-29 Thread Jenda Krynicky
From: [EMAIL PROTECTED] > just about to embark on a sorting routine, and I thought before I > spend ages(at my ability) I would see what thoughts you guys have on > this. As Slobodan Jaksic correctly pointed out a few weeks ago I don't have any thoughts of my own. I just point people to docs :-P

Re: sorting thoughts

2003-01-29 Thread Rob Dixon
"Steven Massey" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] m... > Hi > > just about to embark on a sorting routine, and I thought before I spend > ages(at my ability) I would see what thoughts you guys have on this. > > I have an array, each line contains fields seperated by ":"

Re: sorting thoughts

2003-01-29 Thread david
Steven Massey wrote: > > I have an array, each line contains fields seperated by ":" > I want to sort the array numerically ascending by the last field. > > my thoughts are to split fields into seperate arrays, go through the last > array in a comparing process, moving each row index in the orig

RE: sorting thoughts

2003-01-29 Thread Bob Showalter
david wrote: > Steven Massey wrote: > > > > > I have an array, each line contains fields seperated by ":" > > I want to sort the array numerically ascending by the last field. > > > > my thoughts are to split fields into seperate arrays, go through > > the last array in a comparing process, mov

RE: sorting thoughts

2003-01-29 Thread david
Bob Showalter wrote: > > This will be quicker than the other methods, especially as the array size > grows. Try your benchmark with an array of say 10, or 100 elements. > yes, it's faster. i didn't include the code since this algr. is well known. just some number for those who are interested: B

Re: sorting thoughts

2003-01-30 Thread Janek Schleicher
On Wed, 29 Jan 2003 16:50:03 +, Steven Massey wrote: > I have an array, each line contains fields seperated by ":" > I want to sort the array numerically ascending by the last field. > > my thoughts are to split fields into seperate arrays, go through the last > array in a comparing process,

Re: sorting thoughts

2003-01-30 Thread Steven_Massey
CTED] To: [EMAIL PROTECTED] am.co.uk>cc: Subject: Re: sorting thoughts

Re: sorting thoughts

2003-01-30 Thread Rob Dixon
"Steven Massey" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] m... > > If you could explain how this works, especially how $a $b are set with the > compare values > > my @sorted = sort { > (split ':', $a)[-1] <=> (split ':', $b)[-1] > } @array; The block is evaluated for

RE: Sorting Help!!!

2003-01-30 Thread Beau E. Cox
Hi - > -Original Message- > From: kevin r [mailto:[EMAIL PROTECTED]] > Sent: Thursday, January 30, 2003 8:06 AM > To: [EMAIL PROTECTED] > Subject: Sorting Help!!! > > > Hello, > > I am having problems with the sort routine. I am writing a script that > parses very large firewall logs. At

Re: Sorting Help!!!

2003-01-30 Thread Rob Dixon
Kevin R wrote: > Hello, > > I am having problems with the sort routine. I am writing a script > that parses very large firewall logs. At one point during the script > I end up with a very large array containing all of the destination > udp and tcp port numbers. This array can be up being over 10

Re: Sorting Help!!!

2003-01-30 Thread kevin r
OTECTED] Subject: Re: Sorting Help!!! Date: Thu, 30 Jan 2003 18:34:11 - Kevin R wrote: > Hello, > > I am having problems with the sort routine. I am writing a script > that parses very large firewall logs. At one point during the script > I end up with a very large array containi

RE: Sorting Help!!!

2003-01-30 Thread Wagner, David --- Senior Programmer Analyst --- WGO
tion. Any help would be great, > I have a couple of ideas to make it faster that I am going to try. > > Kevin > > > > >> From: "Rob Dixon" <[EMAIL PROTECTED]> >> To: [EMAIL PROTECTED] >> Subject: Re: Sorting Help!!! >> Date: Thu, 30

RE: Sorting Help!!!

2003-01-30 Thread Bob Showalter
kevin r wrote: > Rob, > > I believe that you are correct in that there is an > alternative answer. > Without posting a long script, here is the premise: > > while logfile { > if (certain conditions are met) > push @portArray, $_ ## pushes certain elements of the $_ into array, > protocol and por

RE: Sorting Help!!!

2003-01-30 Thread kevin r
You guys are the best. It now works, and fast too. Thank you. Kevin From: Bob Showalter <[EMAIL PROTECTED]> To: 'kevin r' <[EMAIL PROTECTED]>, [EMAIL PROTECTED] Subject: RE: Sorting Help!!! Date: Thu, 30 Jan 2003 14:20:09 -0500 kevin r wrote: > Rob, > > I

Re: Sorting Help!!!

2003-01-31 Thread R. Joseph Newton
kevin r wrote: > This becomes a very long list. From here I would sort and then sequentially > step through the array. If the current line does not look like the last > line the print the last line and the number of times it was counted. The > output looks as follows: > > TCP 80 - 25 > TCP 44

Re: sorting logs

2002-08-27 Thread Paul Johnson
On Wed, Aug 28, 2002 at 10:59:13AM +1200, LADDO wrote: > Hi all > > I have a log file which is generated by backup script and i am writing a > perl script to sort the log so as to prepare it to put into mysql > database and iam having a problem in doing that. [ snip ] > i can do it with aw

RE: sorting logs

2002-08-27 Thread David . Wagner
Here is the output I got: "2002-08-28","Tape 1", "staff", "315825" "2002-08-28","Tape 2", "www.cs", "102860" "2002-08-28","Tape 2", "staff_homepages", "103142" "2002-08-28","Tape 2", "ftp.cs", "103204" "2002-08-28","Tape 2", "local", "103216" "2002-08-28","Tape 2", "Hyper-G", "103236" "2

Re: sorting logs

2002-08-27 Thread david
you might want to try: #!/usr/bin/perl -w use strict; my $i = 1; my $min = -1; while(<>){ my($n1,$d1,$b1) = /^INCREMENTAL\s+OF\s+(.+?)\s+.*?ON\s+(.+?)\s+.+\s+(\d+)$/i; $i++ if($b1 < $min); $min = $b1; print "\"$d1\",\"TAPE $i\",\"$n1\",\"$b1\"\n"; } david Laddo

Re: sorting logs

2002-08-27 Thread John W. Krahn
Laddo wrote: > > Hi all Hello, > I have a log file which is generated by backup script and i am writing a > perl script to sort the log so as to prepare it to put into mysql > database and iam having a problem in doing that. > > my log file is like this (I have written line numbers for clar

Re: sorting log

2002-08-28 Thread Felix Geerinckx
on Tue, 27 Aug 2002 22:55:54 GMT, [EMAIL PROTECTED] (Bobby) wrote: > I have a log file which is generated by backup script and i am > writing a perl script to sort the log so as to prepare it to put > into mysql database and iam having a problem in doing that. Something like this? #! perl

Re: sorting log

2002-08-28 Thread Sudarshan Raghavan
On Wed, 28 Aug 2002, bobby wrote: > Hi all > > I have a log file which is generated by backup script and i am writing a > perl script to sort the log so as to prepare it to put into mysql > database and iam having a problem in doing that. > > my log file is like this (I have written line n

Re: sorting log

2002-08-28 Thread Felix Geerinckx
on Wed, 28 Aug 2002 23:36:37 GMT, [EMAIL PROTECTED] (Sudarshan Raghavan) wrote: > On Wed, 28 Aug 2002, bobby wrote: > >> I have a log file which is generated by backup script and i am >> writing a perl script to sort the log so as to prepare it to put >> into mysql database and iam having a pr

Re: sorting directories

2002-11-12 Thread Paul
--- Sukrit K Mehra <[EMAIL PROTECTED]> wrote: > Hi listers, > While doing this --> > @files = readdir(Favorites); > i get an unsorted list in @files. What i desire is directories first > and then files. Using sort function would sort by ascii value and sort > by_name and such won't work too. Ple

RE: sorting directories

2002-11-12 Thread Timothy Johnson
Here's one way: my @dirs = (); my @files = (); opendir(DIR,"/"); my @entries = readdir(DIR); @entries = sort @entries; foreach(@entries){ if(-d "/".$_){ push @dirs,$_; }else{ push @files,$_; } } foreach(@dirs,@files){ print $_."\n"; } -Original Message- From: Sukrit K Me

Re: sorting directories

2002-11-12 Thread John W. Krahn
Sukrit K Mehra wrote: > > Hi listers, Hello, > While doing this --> > > @files = readdir(Favorites); > > i get an unsorted list in @files. What i desire is directories first and > then files. Using sort function would sort by ascii value and sort > by_name and such won't work too. Please sugge

Re: sorting directories

2002-11-12 Thread John W. Krahn
"John W. Krahn" wrote: > > Sukrit K Mehra wrote: > > > > Hi listers, > > Hello, > > > While doing this --> > > > > @files = readdir(Favorites); > > > > i get an unsorted list in @files. What i desire is directories first and > > then files. Using sort function would sort by ascii value and sort

Re: sorting AoA

2004-03-26 Thread Rob Dixon
Guruguhan N wrote: > > I have an array that is build like this > foreach $i ( 0 .. @array1-1) { > foreach $j ( 0 .. @array2-1) { > $array3[$i][$j] = $array2[$j]; > } > } > The array3 has "m" rows and "n" columns of data. > > This code is written by some one else and I am trying to get the statistic

Re: sorting AoA

2004-03-26 Thread John W. Krahn
Guruguhan N wrote: > > Hi , Hello, > I have an array that is build like this > foreach $i ( 0 .. @array1-1) { > foreach $j ( 0 .. @array2-1) { > $array3[$i][$j] = $array2[$j]; > } > } You can use an array slice to do that: @array3[ 0 .. $#array1 ] = map [ @array2 ], 0 .

Re: sorting AoA

2004-03-26 Thread John W. Krahn
Guruguhan N wrote: > > Hi John, Hello, > Thanks for the quick help. I have resolved the problem > with your suggestions. But now I am facing a new problem. Actually > the goal is to get the statistics for each of the data column stored > in a file (FilterMC_3bar_data.out). This file

Re: sorting AoA

2004-03-26 Thread WC -Sx- Jones
if (-s $output_file) { You shouldn't use file test operators to determine whether or nor to open files as there is no guarantee that the test will be valid by the time you open the file. File tests should be done AFTER you obtain a RW lock. This is *supposed* to prevent other system processe

Re: sorting AoA

2004-03-26 Thread James Edward Gray II
On Mar 26, 2004, at 6:06 PM, WC -Sx- Jones wrote: if (-s $output_file) { You shouldn't use file test operators to determine whether or nor to open files as there is no guarantee that the test will be valid by the time you open the file. File tests should be done AFTER you obtain a RW lock.

Re: sorting AoA

2004-03-26 Thread WC -Sx- Jones
James Edward Gray II wrote: if (-s $output_file) { :) There are other reasons to test for a file size prior to opening it :) Why open a data file if it is zero length when you expect data? -- _Sx_ http://youve-reached-the.endoftheinternet.org/ _ perldoc -qa.a | perl -lpe '($_)=m("(.*)")'

Re: sorting AoA

2004-03-27 Thread WC -Sx- Jones
John W. Krahn wrote: Wc -Sx- Jones wrote: James Edward Gray II wrote: if (-s $output_file) { Why are you attributing to James what Guruguhan wrote? :) I'm not -- however that statement was promoted into the portion of the thread that James asked about (which I was replying) so James can tak

Re: sorting AoA

2004-03-27 Thread John W. Krahn
Wc -Sx- Jones wrote: > > James Edward Gray II wrote: > if (-s $output_file) { Why are you attributing to James what Guruguhan wrote? > There are other reasons to test for a file size prior to opening it :) > > Why open a data file if it is zero length when you expect data? What if "-s

Re: sorting AoA

2004-03-27 Thread John W. Krahn
Wc -Sx- Jones wrote: > > John W. Krahn wrote: > > Wc -Sx- Jones wrote: > > > >>James Edward Gray II wrote: > >> > >>if (-s $output_file) { > > > > Why are you attributing to James what Guruguhan wrote? > > :) > > I'm not -- however that statement was promoted into the > portion of the th

Re: sorting AoA

2004-03-27 Thread WC -Sx- Jones
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 discourse of conversation (whether spoken or writte

Re: sorting AoA

2004-03-27 Thread R. Joseph Newton
"N, Guruguhan (GEAE, Foreign National, EACOE)" wrote: > [Implementation stuff snipped] > > Can some one tell me how do I this? Well, if you tellus what you want as output, we could maybe start. Hint--if you really have production code with variable names like @array1, @array2, etc., the best

RE: Sorting Problems

2004-03-30 Thread Charles K. Clarkson
Nigel Peck - MIS Web Design <[EMAIL PROTECTED]> wrote: : : Hi all, : : I'm sure I'm just being stupid here but I can't see where: : : I have an array of hash references that I'm trying to sort by : one of the key/value pairs in the hashes (see code below). : : I get various errors, the current

Re: Sorting Problems

2004-03-30 Thread R. Joseph Newton
Nigel Peck - MIS Web Design wrote: > Hi all, > > I'm sure I'm just being stupid here but I can't see where: > > I have an array of hash references that I'm trying to sort by one of the > key/value pairs in the hashes (see code below). > > I get various errors, the current one being: > > Can't coer

RE: Sorting problem

2002-05-06 Thread Nikola Janceski
take out the spaces @sorted = {$a->[2] <=> $b->[2]} @AoA but this gives a "cannot ^ ^ No spaces should be here > -Original Message- > From: Richard Adams [mailto:[EMAIL PROTECTED]] > Sent: Monday, May 06, 2002 10:18 AM > To: [EMAIL PROTECTED] > S

RE: Sorting problem

2002-05-06 Thread Bob Showalter
> -Original Message- > From: Richard Adams [mailto:[EMAIL PROTECTED]] > Sent: Monday, May 06, 2002 10:18 AM > To: [EMAIL PROTECTED] > Subject: Sorting problem > > > Hello, > I've got an array of arrays, and want to sort by the 3rd > element of the > subarray. I then want to print out t

Re: Sorting problem

2002-05-06 Thread Felix Geerinckx
on Mon, 06 May 2002 14:17:39 GMT, [EMAIL PROTECTED] (Richard Adams) wrote: [Please don't retype code - cut and paste instead] > I've tried > @sorted = {$a ->[2] <=> $b ->[2]} @AoA You forgot the 'sort' function. You put spaces before the '->'. You got the sort order reversed. Try

Re: Sorting problem

2002-05-06 Thread Michael Lamertz
On Mon, May 06, 2002 at 03:17:39PM +0100, Richard Adams wrote: > Hello, > I've got an array of arrays, and want to sort by the 3rd element of the > subarray. I then want to print out the sorted array, showing the index and > values. E.g., Hmm, works for me with the exception of... > I've tried

Re: Sorting problem

2002-05-06 Thread Richard Adams
Thanks for all your help...I just forgot the sort in my post... The reason it wasn't working wasn't the sort, it was just that $AoA[0] was undefined.. But sort {$a->[2] <=> $b->[2]} @AoA[1..$#AoA] works just fine. Thanks again! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional comman

Re: sorting report

2011-02-01 Thread Shlomi Fish
Hi Chris, a few comments on your code: On Tuesday 01 Feb 2011 06:43:43 Chris Stinemetz wrote: > 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 a

RE: sorting report

2011-02-01 Thread Chris Stinemetz
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: On

RE: sorting report

2011-02-01 Thread Chris Stinemetz
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

Re: sorting report

2011-02-01 Thread Rob Dixon
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 = @|||

Re: sorting speed

2007-09-10 Thread Jeremy Kister
On 9/10/2007 4:45 PM, Jeremy Kister wrote: if(@{$hash{$key}} > $highest){ oops, that's if(@{$hash{$key}} > $most){ not $highest. -- Jeremy Kister http://jeremy.kister.net./ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.

Re: sorting speed

2007-09-10 Thread Rob Dixon
Jeremy Kister wrote: I am trying to optimize some sorting code I have. The data structure is as follows: my %hash = (x => [ 'a','b','c' ], y => [ 'd','e' ], z => [ 'f' ], ); The result I expect is simply the highest number of elements. In this case, the

Re: sorting speed

2007-09-10 Thread Jeremy Kister
On 9/10/2007 5:13 PM, Rob Dixon wrote: use List::Util qw/max/; my %hash = (x => [ 'a','b','c' ], y => [ 'd','e' ], z => [ 'f' ], ); my $most = max map scalar @$_, values %hash; Woah! That's fast! :) thanks, -- Jeremy Kister http://jeremy.kister.net./ --

Re: sorting speed

2007-09-10 Thread Chas Owens
On 9/10/07, Jeremy Kister <[EMAIL PROTECTED]> wrote: > I am trying to optimize some sorting code I have. The data structure is > as follows: > > my %hash = (x => [ 'a','b','c' ], > y => [ 'd','e' ], > z => [ 'f' ], > ); > > > The result I expect is simply the

Re: sorting hash

2005-12-26 Thread John Doe
Anders Stegmann am Montag, 26. Dezember 2005 15.22: > Hi! Hello > I have a script like: > > %hash = qw(1 A 2 B 3 C); > while (($key, $value) = each %hash) { > print "$key => $value\n"; > } > > it prints out: > > 1 => A > 3 => C > 2 => B > > I want it to print out a sorted hash like: > > 1 =

RE: sorting hash

2005-12-26 Thread Charles K. Clarkson
Anders Stegmann wrote: : How do I do that? Use 'sort'. use strict; use warnings; my %hash = qw(1 A 2 B 3 C); foreach my $key ( sort { $a <=> $b } keys %hash ) { print "$key => $hash{$key}\n"; } __END__ The big question is: Are you using the right data

RE: sorting hash

2005-12-27 Thread Timothy Johnson
From: Charles K. Clarkson [mailto:[EMAIL PROTECTED] Sent: Mon 12/26/2005 6:40 AM To: beginners@perl.org Cc: Subject: RE: sorting hash Anders Stegmann <mailto:[EMAIL PROTECTED]> wrote: : How do I do that?

Re: Sorting a file

2001-05-13 Thread Jeff Pinyan
On May 13, Thomas Leuxner said: >#mydomain.com >mydomain.com anything >[EMAIL PROTECTED] tlx > >#newdomain.com >newdomain.com anything > > >#somewhere.com >somewhere.com anything > I suggest you make a hash of array reference

Re: Sorting a file

2001-05-13 Thread Jeff Pinyan
On May 13, Jeff Pinyan said: >if (/(?:^|\@)(\S+)/) { I had a precedence error in my code here. That regex will match at the beginning of the line every time. It should be: if (/\@(\S+)/ or /(\S+)/) { # ... } Sigh. And I'm writing a book about these. I should get my act together

Re: Sorting a file

2001-05-14 Thread Jeff Pinyan
On May 14, Paul Cotter said: >next if /^#?$/; # skip empty lines and comment lines No. I had a bad regex weekend (as Paul could personally attest to). The author asked the same question. next if /^(#|$)/; will work, as well next if /^#/ or /^$/; I'm sorry about the mixup. I had origi

Re: SORTING BY DATE

2001-08-06 Thread Peter Scott
[Removed beginners-cgi list; this ha nothing to do with CGIs.] At 04:24 PM 8/6/01 +0930, Daniel Falkenberg wrote: >Does any one know the best way of sortig by YEAR MONTH DAY? > >I would like my script to dispalay 20010327 which is YEAR 2001 MONTH 10 and >DAY 27 A little experimentation should co

RE: SORTING BY DATE

2001-08-06 Thread Chris Rogers
If your data is already in the format shown below as yearmonthday, then a standard sort would do just fine: @test =(20010327, 20001113, 20011225, 19991231, 20100115); foreach (sort @test) { print "$_\n"; } Output will be: 19991231 20010327 20011225 20100115 On the other hand, you may want a

RE: SORTING BY DATE

2001-08-06 Thread Peter Scott
At 11:41 AM 8/6/01 -0400, Chris Rogers wrote: >If your data is already in the format shown below as yearmonthday, then a >standard sort would do just fine: > >@test =(20010327, 20001113, 20011225, 19991231, 20100115); >foreach (sort @test) Doh, I should have realized that this data also sorts asc

Re: sorting hash numerically

2003-02-04 Thread Pete Emerson
perldoc -q sort foreach $empNo (sort {$a<=>$b} keys %empName) { On Tue, 2003-02-04 at 08:17, Rob wrote: > Hi, I want to sort a hash based on the employee number; I used a foreach > loop but it sorts the hash based on the ascii value. How would I get it > to sort on integer values? -- To unsu

Re: Sorting Help (***) URgENT!

2003-07-24 Thread Shawn
I think instead of /$trip/ you ought to use /\Q$trip\E/ Check out the "Quote and Quote-like Operators" section of perlop. On Thu, 2003-07-24 at 14:57, [EMAIL PROTECTED] wrote: > I am trying to get this written for a presentation in the morning (gotta > love it when the boss dumps a pile of stuff

RE: sorting %hash entries

2002-07-22 Thread David . Wagner
Here is one shot: %usernum = ( "server.one.com", "15", "server.two.com", "5", "server.three.com", "14", "server.four.com", "9" ); foreach my $MyId (sort {$a->[1] <=>$b->[1]} map{[$_,$usernum{$_}]} keys %usernum) { printf "%-s\n", $My

Re: sorting %hash entries

2002-07-22 Thread John W. Krahn
Dan wrote: > > I have a small query regarding how to sort hash entries in numerical order. > > %usernum { "server.one.com" "15", > "server.two.com" "5", > "server.three.com" "14", > "server.four.com" "9" } > > How can i get perl to ret

Re: sorting hash entries

2002-07-22 Thread victor
the command 'sort' allow you to put in your own routine to do sorting. %usernum = ("server.one.com" => "15", "server.two.com" => "5", "server.three.com" => "14", "server.four.com" => "9"); @arr = sort {$usernum{$a} <=> $usernum{$b}} (keys %usernum); print j

Re: sorting %hash entries

2002-07-22 Thread dan
ok.. that worked, now how about if i wanted it to go the other way.. from most to least? dan "David Wagner" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Here is one shot: > > > %usernum = ( "server.one.com", "15", > "server.two.com", "5", > "server.three.co

  1   2   3   4   >