Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!ncrlnk!ncr-mpd!Mike.McManus From: Mike.McManus@FtCollins.NCR.com (Mike McManus) Newsgroups: comp.lang.perl Subject: Re: sort Message-ID: Date: 28 Aug 90 15:52:52 GMT References: <1990Aug21.202005.26275@uvaarpa.Virginia.EDU> <1990Aug21.224327.20194@iwarp.intel.com> <1990Aug22.111018.3329@comp.vuw.ac.nz> Sender: uucp@ncr-mpd.FtCollins Organization: NCR Microelectronic Products, Ft. Collins, CO Lines: 34 In-reply-to: Andrew.Vignaux@comp.vuw.ac.nz's message of 22 Aug 90 11:10:18 GMT In article <1990Aug22.111018.3329@comp.vuw.ac.nz> Andrew.Vignaux@comp.vuw.ac.nz (Andrew Vignaux) writes: > > In article <1990Aug21.224327.20194@iwarp.intel.com>, > merlyn@iwarp.intel.com (Randal Schwartz) writes: > >sub by_the_numbers { > > $a - $b; > >} > > The original poster asked about sorting integers so this answer is > right. ... > Is there a better/stronger/faster "float" comparison function than > > sub by_the_numbers { $a > $b ? 1 : $a < $b ? -1 : 0; } > > especially if $a and $b are indexes into an associative array? > e.g ... $foo{$a} > $foo{$b} ? ... Interestingly enuff, I had need for a similar sorting routine today, but with a twist: I want to sort the indices of an associative array that are of the form "A0, A1, A2, ..., A9, A10, ..." Of course an alphabetic sort returns "A0, A10, A11, A19, ..., A1, ...", not what I want! Any simple solutions? Thanks! -- Disclaimer: All spelling and/or grammar in this document are guaranteed to be correct; any exseptions is the is wurk uv intter-net deemuns,. Mike McManus Mike.McManus@FtCollins.NCR.COM, or NCR Microelectronics ncr-mpd!mikemc@ncr-sd.sandiego.ncr.com, or 2001 Danfield Ct. uunet!ncrlnk!ncr-mpd!garage!mikemc Ft. Collins, Colorado (303) 223-5100 Ext. 378