Thanks again...my @lines; { local *FILE; open(FILE, "< filename.in") or die("Couln't open input file: $!\n"); chomp(@lines = <FILE>); } my @sorted_lines = map { $_->[0]} sort ( $a->[1] <=> $b->[1] } map { [ $_, 0+$_ ] } @lines; { local *FILE; open(FILE, "> filename.out") or die("Couln't open output file: $!\n"); local $, = "\n"; print FILE (@lines); } Whats with the curly brackets? Here's what I have tried. It looks like + the file is already ordered alphabetically by id when I used "du -ks + *" but I need it by size which is the numbers. Here's my code, it do +esnt seem to change the order. #Push data into an array die("Cannot open Log file to read from.") unless(open(TAKE, "<unix_list.txt")); while ($line = <TAKE>) { push(@list_all, $line); } close(TAKE); @list_all = sort { $a <=> $b } @list_all; die("Cannot open Log file to write to.") unless(open(NEW, ">unix_list.txt")); print NEW @lines; close(NEW);
In reply to Re^2: Sorting within a file
by Anonymous Monk
in thread Sorting within a file
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |