proper sorting when NetSNMP::OID is available.


git-svn-id: file:///home/hardaker/lib/sf-bkups/net-snmp-convert-svnrepo/trunk@9239 06827809-a52a-0410-b366-d66718629ded
diff --git a/local/mib2c b/local/mib2c
index feb9230..061581b 100755
--- a/local/mib2c
+++ b/local/mib2c
@@ -18,6 +18,7 @@
 
 # SNMP
 my $havesnmp = eval {require SNMP;};
+my $havenetsnmpoid = eval {require NetSNMP::OID;};
 
 if (!$havesnmp) {
     print "
@@ -34,6 +35,9 @@
 if ($havesnmp) {
     eval { import SNMP; }
 }
+if ($havenetsnmp) {
+    eval { import NetSNMP::OID; }
+}
 use FileHandle;
 
 #use strict 'vars';
@@ -623,6 +627,11 @@
 	    if ($#thekeys == -1) {
 	      skippart();
 	    } else {
+	      if ($havenetsnmpoid) {
+		  @thekeys = sort {
+				    new NetSNMP::OID($a) <=> 
+				      new NetSNMP::OID($b) } @thekeys;
+	      }
 	      foreach $scalar (@thekeys) {
 		$fh->seek($startpos, 0); # go to top of section.
 		my $oldvar = $vars{$var};
@@ -644,6 +653,11 @@
 	    if ($#thekeys == -1) {
 	      skippart();
 	    } else {
+	      if ($havenetsnmpoid) {
+		  @thekeys = sort {
+				    new NetSNMP::OID($a) <=> 
+				      new NetSNMP::OID($b) } @thekeys;
+	      }
 	      foreach $notify (@thekeys) {
 		$fh->seek($startpos, 0); # go to top of section.
 		my $oldvar = $vars{$var};
@@ -682,6 +696,11 @@
 	    if ($#thekeys == -1) {
 	      skippart();
 	    } else {
+	      if ($havenetsnmpoid) {
+		  @thekeys = sort {
+				    new NetSNMP::OID($a) <=> 
+				      new NetSNMP::OID($b) } @thekeys;
+	      }
 	      foreach $table (@thekeys) {
 		$fh->seek($startpos, 0); # go to top of section.
 		my $oldvar = $vars{$var};