"be consistent" | |
PerlMonks |
Re: Sorting on a particular field from a Flat File db??by Russ (Deacon) |
on Nov 04, 2000 at 21:11 UTC ( [id://40006]=note: print w/replies, xml ) | Need Help?? |
We are creating our own sort routine, where we can use the keys in the %fields hash, but compare the values belonging to those keys to perform the sort. This will cause a lot of hash lookups, but my benchmarks show that hash lookups are not expensive enough to warrant a Schwartzian Transform. <Update> Oops, didn't read the question</Update> New explanation: We create arrays of fields from each line, storing them in @SplitEntries (each entry in @SplitEntries is an arrayref holding the fields). Now, we can sort the entries on Artist Name. This is not the most CPU-efficient way to do this, either. If your music database is really big, you may want to get the Artist Name for each entry and the array index of its line. Then, sort the names and use the indices to get back to the real array. Even better, you should consider using DBI and let it manage your sorting needs. ;-) Russ
In Section
Seekers of Perl Wisdom
|
|