Do you know where your variables are? | |
PerlMonks |
RE: RE: RE: Sorting an Array?by awwaiid (Friar) |
on Jul 13, 2000 at 20:26 UTC ( [id://22407]=note: print w/replies, xml ) | Need Help?? |
Thanks for the correction :) Naw, the transform doesn't have to modify the sort key... its more general purpose than that (though that is an excellent use). It is just a good algorithm for sorting (array based) data that is more complicated (and or a lot larger) than a plain array. Recently, for instance, I had an array of hashes, and used the transform to sort the array by the contents of one of the hash items. For instance, if we had a phone book or something, consisting of an array of hashes, each hash being an entry ($phonebook[0]{firstname} would access the firstname, for example) we could do the transform to sort by say... or something.
Now, we could indeed do a more complex grabbing of the field we are sorting by and/or a more complex sort algorithm, one in which we needed to modify the key even, but the transform is useful for this case as well. --awwaiid
In Section
Seekers of Perl Wisdom
|
|