in reply to Sorting rows in a text file

When you submitted this question, did you see some text that said:

If something looked unlike you expected it to you might need to check out Writeup Formatting Tips

Did the node look like you expected it to? I doubt it.

To answer your question, sorting in Perl is done using the (strangely named) sort function. You might like to look at the docs for that function.

Your sort seems pretty basic. Assuming you've opened a filehandle called INPUT you can get a sorted list of records like this:

my @data = sort <INPUT>;

By the way, are those supposed to be dates. You might like to give them a closer look :)

Update: To clarify. The data does look like dates, but at least one of them is invalid. All of the others are only valid if you assume MM/DD/YYYY format. If that's the case, then sort sorted example seems a bit strange as you'd be sorting by month, then day, then year which would give bizarre results with a full set of data. Given those facts, together with the fact that the sorted example shows the data sorted in ascii-betical order, I chose to show a simple sort (that gives the right answer with the sample date) and a link to the docs for sort that would be helpful for more complex sorts.

If the data is, in fact, dates, then thinker's answer is, of course, better. However, it's a little inefficient and a Schwartzian transform might be more appropriate.

--
<http://www.dave.org.uk>

"The first rule of Perl club is you don't talk about Perl club."