Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re: (jeffa) Re: Sorting Numbers

by Devo (Initiate)
on Nov 06, 2001 at 10:36 UTC ( #123524=note: print w/replies, xml ) Need Help??

in reply to (jeffa) Re: Sorting Numbers
in thread Sorting Numbers

Yes, I do agree with your idea of simplicity...Open the file, dump in an array, then sort. I would like to solve it in two ways however, and avoid editing so much of the scripts. (This is a series of about 6 different scripts *reaching for aspirin*, all with user defined variables linked together in very odd ways....hence the problem I'm having here).

The data is tab deliminated and looks like this:

17 8/10/01 Joe Blow New York webtherapist www.d I like green-eggs and ham,etc...

That's meant to be perceived as 8 different fields, the first being the number of the entry in which I wish to sort by...descending order of course.

Replies are listed 'Best First'.
Re: Re: (jeffa) Re: Sorting Numbers
by educated_foo (Vicar) on Nov 06, 2001 at 11:07 UTC
    From the perspective of sheer laziness, would it work to replace the
    "local ($a, $b) = @_"
    with a
    "local ($b, $a) = @_"
    ? Reversed sort order, no comprehension or re-writing required.


      Except of course $a and $b aren't actually passed into the sort function like that. Which is presumeably why that line is commented out :-)

      Blessed Be
      The Pixel

        Argh, how disgusting. But this should probably do the trick:
        local ($a, $b) = ($b, $a)
Re: Re: (jeffa) Re: Sorting Numbers
by mkmcconn (Chaplain) on Nov 07, 2001 at 20:04 UTC

    I understand the motive of trying to avoid editing the scripts, Devo, but in the long run if you stick with the previous author's plan, it's too fragile to maintain and impossible to safely extend.

    tilly wrote a nice discussion of Pass by reference vs globals, in a thread of nice discussions that's relevant to the maintenance problem you are facing (thus the need of aspirin)

    The true virtue of laziness is in saving everyone work. It is the most lazy thing, in this case, to edit out the costly, polluting mistakes in that code

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://123524]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (3)
As of 2023-06-10 18:04 GMT
Find Nodes?
    Voting Booth?
    How often do you go to conferences?

    Results (39 votes). Check out past polls.