Path: utzoo!attcan!utgpu!news-server.csri.toronto.edu!mailrus!usenet.ins.cwru.edu!ncoast!allbery From: allbery@NCoast.ORG (Brandon S. Allbery KB8JRR/KT) Newsgroups: comp.lang.perl Subject: Re: sort Message-ID: <1990Sep1.143725.20938@NCoast.ORG> Date: 1 Sep 90 14:37:25 GMT References: <105536@convex.convex.com> <1990Aug29.191454.23527@iwarp.intel.com> <9337@jpl-devvax.JPL.NASA.GOV> Reply-To: allbery@ncoast.ORG (Brandon S. Allbery KB8JRR/KT) Followup-To: comp.lang.perl Organization: North Coast Public Access *NIX, Cleveland, OH Lines: 31 As quoted from <9337@jpl-devvax.JPL.NASA.GOV> by lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall): +--------------- | In article <1990Aug29.191454.23527@iwarp.intel.com> merlyn@iwarp.intel.com (Randal Schwartz) writes: | : In article <105536@convex.convex.com>, tchrist@convex (Tom Christiansen) writes: | : | Is this simple enough for the sort function? | : | | : | sub bynum { substr($a,$[+1,10) > substr($b,$[+1,10); } | : | : Nope nope nope. I made that same mistake once. Think about | : what this returns... either "1" or "0", not "1" or "-1". Arrrgh. :-) | : | : You want something like I already posted involving a test and a 1 or | : -1 return. | | I just had the weirdest thought. The ne and != operators should maybe | return -1 or +1 when the operands aren't equal. +--------------- Not necessary. One change should do it (untested, I have neither the space nor the time to bring up Perl on ncoast): sub bynum { substr($a,$[+1,10) - substr($b,$[+1,10); } The -1/+1 idea is interesting, however. (Another doohickey for the Swiss Army Chainsaw? ;-) ++Brandon -- Me: Brandon S. Allbery VHF/UHF: KB8JRR/KT on 220, 2m, 440 Internet: allbery@NCoast.ORG Delphi: ALLBERY uunet!usenet.ins.cwru.edu!ncoast!allbery America OnLine: KB8JRR