"be consistent" | |
PerlMonks |
Re: two questions that come together into one grand unified questionby premchai21 (Curate) |
on Oct 15, 2001 at 07:58 UTC ( [id://118811]=note: print w/replies, xml ) | Need Help?? |
No, the sorting would not work if they were arrays. Read sort again and you'll see why. Not only that, but hashes are by definition sorted by hash, that is, sorted in a manner only meaningful to the interpreter, probably not to you. However, arrays may or may not be sorted. The problem is that the sort function is non-destructive; it won't sort an array in place, but rather return a new array, which is sorted. Now as for the second problem, I assume you want to print to TEST the contents of playlist, and TEST2 the contents of filelist, with the keys sorted ASCIIbetically. Then you need two for loops:
Now if you want the values sorted instead, then you need to do:
HTH.
In Section
Seekers of Perl Wisdom
|
|