Hi,
I have an array @data that is loaded from a file layed out like so:
Billy Bob|Smith|5|Yes
Jim Steven|Brown|3|Yes
Joe John|Bloggs|4|Yes
my question is how can I sort that array by the number column and return it as an array?
I have figured that
will sort an array of arrays but that won`t work for this kind of array.
I feel that somewhere in there I should split the data on the pipe but I have tried all sorts of combinations without success.
Any pointers much appreciated.
Cheers
chmod
I have an array @data that is loaded from a file layed out like so:
Billy Bob|Smith|5|Yes
Jim Steven|Brown|3|Yes
Joe John|Bloggs|4|Yes
my question is how can I sort that array by the number column and return it as an array?
I have figured that
Code:
@sorted_data = sort {$a->[2] <=> $b->[2]} @data;will sort an array of arrays but that won`t work for this kind of array.
I feel that somewhere in there I should split the data on the pipe but I have tried all sorts of combinations without success.
Any pointers much appreciated.
Cheers
chmod