in reply to Re: Complex hash sorting
in thread Complex hash sorting
Your first method seems to be easier to understand/follow, though I've never seen things done like this before...so I'll try going with that. Can you explain what/why $criteria is and why it's 3? And after it's in an array, how would you split everything back into separate variables for printing?
This is an example of my actual coding
There are four values (including the key itself), I want to make three of these sortable: the key, $count and $time). My method of doing this is calling a url_param defining the choice of sort. Ie. script.cgi?sort_by=count or script.cgi?sort_by=key and depending on what they chose, a different hash sort method will be used.tie %db, "DB_File", "$db", O_CREAT | O_RDWR, 0644, $DB_BTREE or die "Cannot open file 'db': $!\n"; print "<table>"; foreach (keys %db) { my ($count, $ip, $time) = split(/\|\|/, $db{$_}); print "<td>$count</td><td>$ip</td><td>$time</td>"; } </table>
Thanks for your time.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Complex hash sorting
by flyingmoose (Priest) on Feb 02, 2004 at 19:16 UTC |