Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^2: A more efficient sort or heap algorithm...

by bioinformatics (Friar)
on Apr 28, 2009 at 22:35 UTC ( [id://760772]=note: print w/replies, xml ) Need Help??


in reply to Re: A more efficient sort or heap algorithm...
in thread A more efficient sort or heap algorithm...

I'm still learning about efficiency (obviously), but the benefit of using the hand coded sort was to allow me to have two arrays sorted the same way (but based on the first, if that makes sense), with the second array containing a hash key leading to the data for the corresponding region. I wasn't sure how to implement that using the built in sort function. It allows me to keep track of and print out the information for both regions.
Bioinformatics
  • Comment on Re^2: A more efficient sort or heap algorithm...

Replies are listed 'Best First'.
Re^3: A more efficient sort or heap algorithm...
by przemo (Scribe) on Apr 28, 2009 at 22:51 UTC
    I wasn't sure how to implement that using the built in sort function. It allows me to keep track of and print out the information for both regions.

    Just try to sort the indices and then map both arrays by them:

    my @ind_srtd = sort { $array->[$a] cmp $array->[$b] } (0..$#$array); my @array_srtd = map { $array->[$_] } @ind_srtd; my @array_which_srtd = map { $array_which->[$_] } @ind_srtd;

    I didn't tested it thoroughly, but should look something like this.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2024-04-23 23:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found