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; > >