--- odmrd.pl.orig	Sat Aug  3 16:12:57 2002
+++ odmrd.pl	Thu Sep  4 11:16:27 2003
@@ -454,6 +454,16 @@
     my $dir = $spool."/".$dom."/";
     opendir(DIR, $dir) || next;
     my @msgs = readdir(DIR);
+    # sort @msgs so that the smallest is first
+    my %hash=();
+    foreach $msg (@msgs) {
+      next if $msg =~ /^\..*$/;
+      $hash{$msg}=(-s $dir."/".$msg);
+    }
+    @msgs=();
+    foreach $key (sort { $hash{$a} <=> $hash{$b} } keys %hash) {
+      push @msgs,$key;
+    }
     foreach $msg (@msgs) {
       next if $msg =~ /^\..*$/;		# skip . and ..
       $mails_waiting++;			# count messages
