--- mkgallery.pl	Sun Jun 13 11:29:54 2004
+++ mkgallery.pl.mod	Sun Jun 13 11:49:06 2004
@@ -234,8 +234,19 @@
     print "Creating meta index\n" if ( $P{verbose} );
     my @galleries;
     if ( opendir ( DIR, $P{img_dir} ) ) {
-	my @dir = sort ( readdir ( DIR ) );
-	close ( DIR );
+    	my @dir;
+	if ( -f "$P{img_dir}/.bbsorting" ) {
+	    print "Reading alternative sorting list\n" if ( $P{verbose} );    	
+	    if ( open ( SRT, "$P{img_dir}/.bbsorting" ) ) {
+		@dir = <SRT>;
+		chomp(@dir);
+		close( SRT );
+	    }
+	}
+	else {
+	    @dir = sort ( readdir ( DIR ) );
+	}
+   	close ( DIR );
 
 	foreach my $d ( @dir ) {
 	    if ( open M, "$d/.bbmeta" ) {
@@ -681,7 +692,21 @@
 
 # read in all the thumbs
 if ( opendir ( TH, "$P{img_dir}/thumbs" ) ) {
-    my @thumbs = sort ( readdir ( TH ) );
+    my @thumbs;
+    if( -f "$P{img_dir}/.bbsorting" ) {
+	print "Reading alternative sorting list\n" if ( $P{verbose} );    
+	if ( open ( SRT, "$P{img_dir}/.bbsorting" ) ) {
+	    @thumbs = <SRT>;
+	    chomp(@thumbs);
+	    for( my $I = 0; $I < scalar@thumbs; $I ++ ) {
+		$thumbs[$I] = "th_".$thumbs[$I];
+	    }
+	    close( SRT );
+	}
+    }
+    else {
+	@thumbs = sort ( readdir ( TH ) );
+    }
     closedir ( TH );
     my @img;
     my @idx;
--- doc/usage.html	Sat Mar 15 23:57:13 2003
+++ doc/usage.html.mod	Sun Jun 13 11:56:40 2004
@@ -210,6 +210,32 @@
                     </td>
                   </tr>
                   <tr>
+                    <td valign="top"><u><b>Sorting</b></u><br>
+                    </td>
+                  </tr>
+                  <tr>
+                    <td valign="top">The images in the gallery gets sorted in
+		    alphabetic order by their name. The same is true for the
+		    galleries in the meta index. If you want to make use of a
+		    custom sort order, you can override this sorting style by
+		    defining a '<tt>.bbsorting</tt>' file.<br>
+		    <br>
+		    In case of a gallery, simply place the '<tt>.bbsorting</tt>'
+		    file into the image directory. Then put the file names - of the
+		    images you wanted to have in your gallery - into this file (for
+		    instance with <tt>ls -1 *.jpg &gt;.bbsorting</tt>) and sort then
+		    based on your preferences.<br>
+		    <br>
+		    In case of the meta index, place the '<tt>.bbsorting</tt>'
+		    into the subdirectory where all your image directories resist.
+		    Then put all subdirectories - of the galleries you wanted to
+		    have in your meta index - into this file (just the subdirectory
+		    names without trailing slashes) and sort them based on your
+		    preferences.<br>
+                    <br>
+                    </td>
+                  </tr>
+                  <tr>
                     <td valign="top"><u><b>Persistent Settings, Defaults</b></u><br>
                     </td>
                   </tr>
