home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.perl
- Path: sparky!uunet!etnibsd!vsh
- From: vsh@etnibsd.uucp (Steve Harris)
- Subject: Re: Ordering indices based on their values
- Message-ID: <1992Aug28.214803.2432@etnibsd.uucp>
- Organization: Eaton Corp, Semiconductor Equipment Div., Beverly, MA
- References: <GLENN.92Aug26122420@capella.clsi.COM>
- Distribution: comp.lang.perl
- Date: Fri, 28 Aug 1992 21:48:03 GMT
- Lines: 12
-
-
- @array = (7,2,4,-1,5);
- print join(' ',&idx_sort(@array)), "\n";
-
- sub idx_sort {
- # returns indicies of input array sorted by values of input array
- local($i) = 0;
- grep(s/.*\t//,sort(numeric grep($_ .= "\t" . $i++,@_)));
- }
- sub numeric { $a <=> $b; }
- --
- ... Steve Harris - Eaton Corp. - Beverly, MA - uunet!etnibsd!vsh
-