in reply to Re: criteria based array sorting
in thread criteria based array sorting

That's not a Schwartzian Transform, but a GRT. The code is structurally similar, but works slightly differently. Though some consider the GRT to be a subset of the ST, this is a matter of debate.

----
: () { :|:& };:

Note: All code is untested, unless otherwise stated

Replies are listed 'Best First'.
Re: Re: Re: criteria based array sorting
by Limbic~Region (Chancellor) on Feb 12, 2004 at 20:41 UTC
    hardburn,
    Actually it is a variation on the GRT that tye likes to call The One True Sort. The subtle difference is that you do not have to restore the transformation - you can simply throw it away. An example of a classicle GRT would be:
    #!/usr/bin/perl use strict; use warnings; my @needs_sorting = qw(Psdgs ldfgs Esdds aSdg Sgsdfs esdf sgfsdfg Osgr + T); @needs_sorting = map { /^[a-z]/ ? "\u$_" : "\l$_" } sort map { /^[a-z]/ ? "\u$_" : "\l$_" } @needs_sorting; print "$_\n" for @needs_sorting;
    Cheers - L~R
      Actually it is a variation on the GRT that tye likes to call The One True Sort.
      Actually it's not. The One True Sort sorts array indices.
      What we have here is a run-of-the-mill GRT. Which, btw, is a sub-species of the ST. No debate about it. :-)

      jdporter
      The 6th Rule of Perl Club is -- There is no Rule #6.