in reply to Sorting a large data set
If you want to write them to disk, yeah, you're pretty much gonna have to format the records one-per-line as you write them. If you're on a unix system, calling an external sort(1) might even be quicker than File::Sort (I'll bet it is).
A third consideration is this: if the elements are huge create an "index" array that just has the numbers 0..$#list in it. Then sort it like this:
At this point you can just use index to access the array elements in sorted order. Problem is in your case that you've just got arrays of references (the things you're sorting aren't huge, the list itself is). I'm not sure an @index array of Sv's is gonna be that much smaller than the references. If that were the case then you could just unwind it with $_=$huge[$_] for(@index); later.for(0..1000) { push(@huge, {key=>rand, value=>'hlaghlagh'})} @index=(0..$#huge); @index=sort { $huge[$a]->{key} <=> $huge[$b]->{key} } @index;
12k elements doesn't seem like that much, though. Hrm.
<super>*</super>I always though an in-place sort would be a great use for scalar or void context sort. I haven't got the know-how to come up with the patch for that though.
|
|---|