Efficient sorting of SNMP oids

Dave Hodgkinson davehodg at gmail.com
Sat Oct 31 20:06:49 GMT 2009


On 31 Oct 2009, at 16:03, B Maqueira wrote:

> Dear all,
>
> I need to sort eficiently a large array (~9000) of SNMP OIDs.
>
> I am currently trying the following code:
>
> my @sorted_oids = map { $_->[0] }
>                                  sort { $a->[1] cmp $b->[1] }
>                                     map { [$_, pack('w*', split(/\./,
> $_))]  } @oids;
>
> But this fails since it outputs 1.3.6.1.4.1.2333.3.2.61001.1.10 before
> than 1.3.6.1.4.1.2333.3.2.8080.1.1.1
>
> Any ideas?

Convert them to 256 bit (or whatver integers), sort and convert back? :)

-- 
Dave Hodgkinson                                MSN: davehodg at hotmail.com
Site: http://www.davehodgkinson.com                  UK: +44 7768 490620
Blog: http://www.davehodgkinson.com/blog
Photos: http://www.flickr.com/photos/davehodg










More information about the london.pm mailing list