in reply to Re: sort question
in thread sort question

Hey mda2, I tweaked it a bit and it works, but I have NO idea why or how:
sub sort_ranks { my @array = map {$_->[0]} sort {($a->[1]=~/^R#(\d+)$/)[0] <=> ($b->[1] +=~/^R#(\d+)$/)[0]} map {[$_,$entry{$table}{$_}{RANK}]} @_; }
In fact, I think I'll use this as my JAPH ;-)

Replies are listed 'Best First'.
Re^3: sort question
by mrborisguy (Hermit) on May 17, 2005 at 18:59 UTC
    if you don't know how it works, i really hope you're not using it for anything important! otherwise you'll be in trouble when you try to maintain it in a couple months! "now why did i do it like this... well, turns out i didn't even know then, and i'm more clueless now!"

    this is what is called a Schwartzian Transform, so check out 441762 and http://www.sysarch.com/perl/sort_paper.html
      Hey...okay... interesting. Now I know what a Schwartzian Transform is. I've seen it mentioned before, but now I know. Thanks, boris!
      Actually, the main issue is that I rarely use 'map', and I should, so this is a good learning experience.