in reply to Re: Ordering objects using external index
in thread Ordering objects using external index

Aa, kind of. Look:
my $uids = [ 5674, 1, 4 ]; my $msgs = [ $msg1, $msg4, $msg5674 ];
Provided $msgNN->uid == NN we'd like to have [ $msg5674, $msg1, $msg4 ].

Replies are listed 'Best First'.
Re^3: Ordering objects using external index
by BrowserUk (Patriarch) on Sep 06, 2004 at 21:36 UTC

    That makes it look like your using symbolic references? Ie. Variable names that are (partially) made up from other variable names. eg.

    $uid = 5674; ${'msg' . $uid } = ...;

    In which case, you should be making that a hash directly:

    push @uid, 5674; $msgs{ $uid[ -1 ] } = ...;

    then you wouldn't be having the mapping problem later on. Producing your ordered array would then become a simple hash slice:

    @ordered = @msgs{ @uid };

    It's difficult to know without seeing how the variables and data in your snippets are beiing created.


    Examine what is said, not who speaks.
    "Efficiency is intelligent laziness." -David Dunham
    "Think for yourself!" - Abigail
    "Memory, processor, disk in that order on the hardware side. Algorithm, algorithm, algorithm on the code side." - tachyon

      No, of course not, I don't use symbolic references, sorry for confusion.

      I have an array of messages, not a hash. The operation of converting that array to hash keyed by one of message properties (namely, uid) is exactly what I want to avoid as it is expensive.

      I like your suggestion, though, of not having that message array in the first place, but I think this is hard to implement. At present the only format of getting those messages is in unordered lists, too bad (there's IMAP on the other end).