Sort returns the array sorted, it does not sort it in place. So just move your sort into the foreach
foreach my $line(sort @resultArray){Now it uses the sorted array returned from the sort. Alternately you could modify your sort line to save that back into the orignal array.
@resultArray = sort { $a<=>$b } @resultArray;Could anyone comment as to why sort doesn't do an inplace sort when called in void context?
In reply to Re: Sort textfile
by eric256
in thread Sort textfile
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |