in reply to Sorting colon-delimited records

I would reccomend using an array of arrays and sorting the references to the arrays based on the value of the second element. For the sake of argument, I am going to assume that you have colon-delimited fields, one record per line, and that all the data has been loaded into $data.

#!/usr/bin/perl -w use strict; my $data = get_data_from_somewhere; # First split the data up into a 2D structure my @struct; for (split /\n/, $data) { push @struct, [ split /:/ ] } # Now we sort the struct on the second element of the nested arrays @struct = sort { $a->[1] cmp $b->[1] } @struct;