PerlingTheUK has asked for the wisdom of the Perl Monks concerning the following question:
would sort all values, returning ( 0000, 1245, 1246, ... ). I only wish to move larger numbers to the end, returning (1245,0000,1246,1247,1248). Writing a new sort algorithm would solve this, but I was wondering, if there is a way to teach sort to do so, and if this was possibly faster. Actually by pre-sorted I mean that all larger values simply need to be sorted upwards in the array, so 1248 will be at the end while in the end while the other values are in the right order already.@ar = ( 1245, 1248, 0000, 1246, 1247 ); sort{ $a <=> $b } @ar;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Exceptional sorting
by Corion (Patriarch) on May 25, 2004 at 10:28 UTC | |
by pelagic (Priest) on May 25, 2004 at 10:37 UTC | |
by PerlingTheUK (Hermit) on May 25, 2004 at 10:43 UTC | |
|
Re: Exceptional sorting
by Abigail-II (Bishop) on May 25, 2004 at 10:43 UTC | |
by PerlingTheUK (Hermit) on May 25, 2004 at 10:49 UTC | |
by Abigail-II (Bishop) on May 25, 2004 at 11:07 UTC | |
by PerlingTheUK (Hermit) on May 25, 2004 at 11:40 UTC | |
by Abigail-II (Bishop) on May 25, 2004 at 11:51 UTC | |
by Corion (Patriarch) on May 25, 2004 at 11:50 UTC | |
by Solo (Deacon) on May 25, 2004 at 14:45 UTC | |
|
Re: Exceptional sorting
by CountZero (Bishop) on May 25, 2004 at 10:21 UTC | |
by PerlingTheUK (Hermit) on May 25, 2004 at 10:52 UTC | |
by CountZero (Bishop) on May 25, 2004 at 19:56 UTC | |
|
Re: Exceptional sorting
by pelagic (Priest) on May 25, 2004 at 14:12 UTC |