Efficient sorting of SNMP oids

Uri Guttman uri at StemSystems.com
Sat Oct 31 19:11:23 GMT 2009


>>>>> "BM" == B Maqueira <bmi at ferrarihaines.com> writes:

  BM> Dear all,
  BM> I need to sort eficiently a large array (~9000) of SNMP OIDs.

  BM> I am currently trying the following code:

  BM> my @sorted_oids = map { $_->[0] }
  BM>                                   sort { $a->[1] cmp $b->[1] }
  BM>                                      map { [$_, pack('w*', split(/\./,
  BM> $_))]  } @oids;

  BM> But this fails since it outputs 1.3.6.1.4.1.2333.3.2.61001.1.10 before
  BM> than 1.3.6.1.4.1.2333.3.2.8080.1.1.1

sort::maker could do that and generate a faster sort with the GRT. just
generate an array of integers (or shorts) and pack them for the
key. similar to what you have there.

uri

-- 
Uri Guttman  ------  uri at stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------


More information about the london.pm mailing list