Re: Perl sort for reverse numeric if numbers and text are in a string, numbers first

2016-03-09 Thread Brock Wilcox
Probably you have "use warnings" turned on. You can disable the warning for numeric comparison with "no warnings 'numeric';" perl -E 'use warnings; no warnings "numeric"; my @a = ("12\thi","37\tb","123\tc","187\ta"); my @b = sort { $a <=> $b } @a; say join("\n",@b)' 12 hi 37 b 123 c

Re: Perl sort for reverse numeric if numbers and text are in a string, numbers first

2016-03-08 Thread Shawn H Corey
On Tue, 8 Mar 2016 13:29:40 -0800 Kenneth Wolcott wrote: > How do I call the built-in Perl sort function on an array of strings > where the string is composed of one or more digits, followed by a tab > which is followed by a string and I want the results to be sorted in > reverse numeric order?

Re: Perl sort for reverse numeric if numbers and text are in a string, numbers first

2016-03-08 Thread Andrew Solomon
Hi Ken I just wrote this https://gist.github.com/andrewsolomon/65b795be10da569f878d and then realised it could be simpler because you'll have a tab between the number and string. Does this give you enough to work off? Andrew On Tue, Mar 8, 2016 at 9:29 PM, Kenneth Wolcott wrote: > Hi; > >

Re: perl sort

2009-02-07 Thread Raymond Wan
Hi all, Chas. Owens wrote: Well, I would suggest taking this to the Perl Porters list*, this is a list for people who are starting to learn Perl. You could also write a module implementing you algorithm either in pure Perl or in XS** (the interface between ISO C and Perl) and upload it to CPAN

Re: perl sort

2009-02-07 Thread Chas. Owens
On Sat, Feb 7, 2009 at 22:41, Marion McCoskey wrote: > I am a retired programmer, and I haven't had a lot of trouble with the > couple of thousand lines of Perl I have written, except remembering to > always put in curly braces. But I don't know anything about the Perl > community. > > While look

Re: perl sort

2009-02-07 Thread Raymond Wan
Hi Marion, Marion McCoskey wrote: While looking at the documentation for the sort function, I noticed it complaining about the shortcomings of the quick sort. I share that feeling and I have developed a single-buffered count sort that is faster than the quick sort and a lot more stable. Act

Re: perl sort query

2007-06-19 Thread Rob Dixon
pauld wrote: John W. Krahn wrote: It sorts fine here: $ perl -le' print for @x = qw/200610011733 200610012057 200610011029 200610010928 200610011220/, ""; print for sort @x; ' 200610011733 200610012057 200610011029 200610010928 200610011220 200610010928 200610011029 200610011220 2006100117

Re: perl sort query

2007-06-19 Thread pauld
> $ perl -le' > print for @x = qw/200610011733 200610012057 200610011029 200610010928 > 200610011220/, ""; > > print for sort @x; > ' > 200610011733 > 200610012057 > 200610011029 > 200610010928 > 200610011220 > the time is the last 4 digits (hhmm) so the first is 17:33 then 20:57 then 10:29 then

Re: perl sort query

2007-06-18 Thread John W. Krahn
pauld wrote: I want to sort a hash of hash by date&time and then extract some of the data. From the data ive got i can contruct a key that is mmddhhmm and i do this ##error trap absent entries if ($endan=~m/\d{2}:\d{2}\s+\d{2}/ && $stan=~m/\d{2}:\d{2}\s+\d{2}/ ) {my %daylist; #