http://www.perlmonks.org?node_id=152343

Kratimoyporroon has asked for the wisdom of the Perl Monks concerning the following question:

Basically, I have a bunch of data I've gathered from an online forum: name, time, post length, and some other random statistics. I want to be able to sort this data by several different fields. Say, first by time and then by name. What data structure do you recommend, and are there any build in methods to sort this stuff? Could you give a brief example? Thanks.

Replies are listed 'Best First'.
Re: Advice - storing data - which structure do you recommend? (details inside)
by tachyon (Chancellor) on Mar 17, 2002 at 20:40 UTC
Re: Advice - storing data - which structure do you recommend? (details inside)
by zengargoyle (Deacon) on Mar 17, 2002 at 20:18 UTC
Re: Advice - storing data - which structure do you recommend? (details inside)
by cyocum (Curate) on Mar 17, 2002 at 22:43 UTC

    If you want to stay within Perl to do this, you could use the Perl sort function. It allows you to write what is basically an anonymous sub to let you sort anyway you want. Of couse, this puts a constraint on your data structure to an array but if all the attributes are always in the same order then it does not make much difference.