Hi Kenneth, On Fri, 17 Jun 2016 14:41:41 -0700 Kenneth Wolcott <kennethwolc...@gmail.com> wrote:
> On Fri, Jun 17, 2016 at 2:33 PM, Kenneth Wolcott > <kennethwolc...@gmail.com> wrote: > > Hi; > > > > I'm having trouble understanding the built-in Perl sort with regards > > to mixed numbers and strings > > > > I'm looking at http://perldoc.perl.org/functions/sort.html > > > > I have an array that I want to have sorted numerically and descending. > > > > The array is composed of elements that look like the following regex: > > > > ^\d+\t\[a-zA-Z0-9]+$ > > > > I always have "use strict" at the top of my Perl scripts. > > > > If I try: > > > > my @articles = sort {$b <=> $a} @files; > > > > I get error(s)/warning(s) that the data is not numeric. > > > > if I try: > > > > my @articles = sort {$b cmp $a} @files; You can chain several comparator clauses using the "||" or "or" operators. See: http://perl-begin.org/tutorials/perl-for-newbies/part4/#page--and_or--DIR Perhaps use the Schwartzian transform in this case and then do that: https://en.wikipedia.org/wiki/Schwartzian_transform Regards, Shlomi Fish -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/