in reply to sorting comma separated value file

Update: I thought this was an original idea. Instead of using the other methods everyone else was suggestion I attempted (succesfuly i might add) to create a hash with the column to be sorted as the key, and the whole string as the value for the key. Sort the hash keys and you're done (probably). Oh well, I guess it wan't novel enough (someone didn't like it).
--------end of update--------------
Being that you are using this to learn, I will stick mostly to the theory (of how I would do it). I found this to be one novel way attack the problem.

I would start by creating a hash with the keys of the hash equivalent to the values of the column you are sorting on.
Use the desired field for the hash key (the ".=" covers multiple keys of the same name (tho not sorting them later))

foreach my $line (@file) { chop ($line); $line =~ s/ //g; my @values = split (/,/, $line); $thehash{$values[$field]} .= "$line\n"; }

Once the hash is created, sort it and print it:

@keys = sort(keys %thehash); foreach (@keys) { print "$thehash{$_}"; }

This will cover having two identical key values, but will not sort them appropriately (at least in my mind)
e.x.- (sorted on first field, it doesn't look to the second field for more clarification)
99,bbbc,5fa3aaa
99,ccc,2143
It will only sort the actual field specified.

I leave fixing that to the reader.

Then again you could just put the data into a database and use SQL.