difficult perl sort - TechRepublic
General discussion
September 8, 2000 at 04:20 AM
anthonyc

difficult perl sort

by anthonyc . Updated 25 years, 8 months ago

I have to set up a perl sort. I need to sort an array of hashs. Basicaly I have an array and in eache element of this array is an anonymous hash. Whithin this hash is a list of key value pairs, three of these pairs have the date in the form of year=>yyyy, month=>mm, day=>dd. What I need to do is to sort this array in order by date.

Sample:

@array = ( {year=>2000,month=>12,day=>19},
{year=>2000,month=>1,day=>20},
{year=>1999,month=>7,day=>8},
{year=>2000,month=>12,day=>26}
{year=>1998,month=12,day=>26} );

I would need this sorted in date order in the array from $array[0] to $array[whatever] so that as new elements are added once i run the sort it would place that element in the appropriate place within the arrray.

500 points for this one.

thanks
Anthony C

This discussion is locked

All Comments