in reply to Re: Re: Sorting issues
in thread Sorting issues

> Just be aware that you'll be using 3-4 times the memory for this data structure.

Thanks for pointing that out, I didn't know.
update: Now that I think of it, I find it unfortunate that better design would carry such a high cost... But I know, that's Perl: equivalent speed at the cost of higher resource usage.

> You can't do sequential sorts and expect it to still be sorted by the previous order

Hmmm, didn't think about that. For my personal knowledge, then, how would you sort by one criteria and then by another? Something similar to the above?
sort { $a->{z} <=> $b->{z} || $a->{x} <=> $b->{x} } @points;
???

Replies are listed 'Best First'.
Re: Re: Re: Re: Sorting issues
by jmanning2k (Pilgrim) on Jan 09, 2004 at 20:40 UTC

    Yes, that sort will work. In the original example, the second sort simply undid the results of your first sort.

    In your new sort, the part after '||' will only happen if $a->{z} == $b->{z}, so it works like you want it to.

      Ah, thanks jmanning2k. Still learning even as I try to answer questions!