Subject: Sorting associative arrays in perl
From: Leif Sawyer (lsawyer@gci.com)
Date: Tue May 07 2002 - 16:15:19 AKDT
I've got a bizarre question, probably better suited to the perl-mongers
list, but i've lost all info for that, and haven't seen a post in quite
some time.
I've got an associative array: %data
which is initialized like this from a datafile
$data{$timestamp} = value;
I would like to:
1) sort ascending, primarily, by the value (value is not unique)
2) sort ascending, secondarily, by the timestamp (timestamp is
unique)
3) print the array
the output should resemble:
100, 200204311201
240, 200203192104
240, 200203192205
242, 200204301300
301, 200203302048
I can't figure out how to write the sort subroutine to perform this
type of sort.
ps. Yes, i'm using it for MRTG logs.
I'd be happy to share the application once its working correctly.
Thanks!
Leif
---------
To unsubscribe, send email to <aklug-request@aklug.org>
with 'unsubscribe' in the message body.
This archive was generated by hypermail 2a23 : Tue May 07 2002 - 16:15:22 AKDT