|The stupid question is the question not asked|
Re: How to sort an arrayby jarich (Curate)
|on Jul 07, 2004 at 13:23 UTC||Need Help??|
Just to be clear, you have an array consisting of lines like the one you describe above? So your data could be constructed with something like the following?
If that is correct, then you can use something like the following to achieve your aim:
Please note that the above will only work for numeric input. You can change it to use string compare by replacing the <=> with cmp.
I would suggest thinking about what you're doing with this data, however. If you're going to be accessing bits of it more than just this time, then perhaps you should be using an array of hashes or at least and array of arrays? See perlreftut.
If you break this into an array of hashes:
You can access individual items as follows:
This might make it easier to sort, too.
As I said, it depends on how much manipulation is required on the input.
I hope this helps