--- ./bin/rancid.in.aclsort	2006-08-12 04:34:22.000000000 +0200
+++ ./bin/rancid.in	2006-09-13 20:40:36.000000000 +0200
@@ -35,6 +35,7 @@
 $found_env = 0;
 $found_diag = 0;
 $timeo = 90;				# clogin timeout in seconds
+$aclsort = "ipsort";
 
 my(@commandtable, %commands, @commands);# command lists
 my(%filter_pwds);			# password filtering mode
@@ -1593,14 +1594,14 @@
 	s/\$(Revision|Id):/ $1:/;
 	# order access-lists
 	/^access-list\s+(\d\d?)\s+(\S+)\s+(\S+)/ &&
-	    ProcessHistory("ACL $1 $2","ipsort","$3","$_") && next;
+	    ProcessHistory("ACL $1 $2","$aclsort","$3","$_") && next;
 	# order extended access-lists
 	/^access-list\s+(\d\d\d)\s+(\S+)\s+ip\s+host\s+(\S+)/ &&
-	    ProcessHistory("EACL $1 $2","ipsort","$3","$_") && next;
+	    ProcessHistory("EACL $1 $2","$aclsort","$3","$_") && next;
 	/^access-list\s+(\d\d\d)\s+(\S+)\s+ip\s+(\d\S+)/ &&
-	    ProcessHistory("EACL $1 $2","ipsort","$3","$_") && next;
+	    ProcessHistory("EACL $1 $2","$aclsort","$3","$_") && next;
 	/^access-list\s+(\d\d\d)\s+(\S+)\s+ip\s+any/ &&
-	    ProcessHistory("EACL $1 $2","ipsort","0.0.0.0","$_") && next;
+	    ProcessHistory("EACL $1 $2","$aclsort","0.0.0.0","$_") && next;
 	# order arp lists
 	/^arp\s+(\d+\.\d+\.\d+\.\d+)\s+/ &&
 	    ProcessHistory("ARP","ipsort","$1","$_") && next;
@@ -1819,6 +1820,11 @@
     $filter_pwds = 1;
 }
 
+# check ACL sorting mode
+if (defined($ENV{"ACLSORT"}) && $ENV{"ACLSORT"} =~ /no/i) {
+    $aclsort = "";
+}
+
 ProcessHistory("","","","!RANCID-CONTENT-TYPE: cisco\n!\n");
 ProcessHistory("COMMENTS","keysort","B0","!\n");
 ProcessHistory("COMMENTS","keysort","D0","!\n");
--- ./etc/rancid.conf.sample.in.aclsort	2005-08-15 02:42:50.000000000 +0200
+++ ./etc/rancid.conf.sample.in	2006-09-13 20:47:08.000000000 +0200
@@ -41,6 +41,9 @@
 # if NOCOMMSTR is set, snmp community strings will be stripped from the configs
 #NOCOMMSTR=YES; export NOCOMMSTR
 #
+# Set ACLSORT to NO to disable the sorting of the ACLs.
+#ACLSORT=YES
+#
 # How many times failed collections are retried (for each run) before
 # giving up.  Minimum: 1
 #MAX_ROUNDS=4; export MAX_ROUNDS
