in reply to Re: Re: Sort textfile
in thread Sort textfile

You have two problems in your code.

(1) sort @array
does not sort the array, it returns the sorted array

(2) sort {$a <=> $b} @array
sorts numbers, not strings.

To fix this, use default sorting of sort (or explicitly compare strings) and assign it to a new array.

@sorted = sort @array;
or
@sorted = sort {$a cmp $b} @array;

Sandy