in reply to Multiple Sort on a file

There is also a more compact way to do this called the Schwartzian Transform. In this case that comes out to the script:
#! /usr/bin/perl print map {join ",", @$_} sort {$a->[2] cmp $b->[2] or $a->[0] <=> $b->[0]} map {[split /,/, $_, 3]} <>;
which should be read after reading about map, and should be read bottom up. You would call it like this:
perl scriptname < input_file > output_file