push(@buf, $1);

...

print join("\n", sort(@buf));