--- /usr/local/src/perl/DBIx-SearchBuilder-0.80/SearchBuilder.pm	Sat Mar  8 02:42:25 2003
+++ SearchBuilder.pm	Tue Mar 11 17:35:33 2003
@@ -863,23 +863,70 @@
 sub OrderBy {
     my $self = shift;
     my %args = ( ALIAS => 'main',
-                 FIELD => undef,
-                 ORDER => 'ASC',
-                 @_ );
-    $self->{'order_by_alias'} = $args{'ALIAS'};
-    $self->{'order_by_field'} = $args{'FIELD'};
-    if ( $args{'ORDER'} =~ /^des/i ) {
-        $self->{'order_by_order'} = "DESC";
+		 FIELD => undef,
+		 ORDER => 'ASC',
+		 @_
+	       );
+    if ($args{'ORDER'} =~ /^des/i) {
+	$args{'ORDER'} = "DESC";
     }
     else {
-        $self->{'order_by_order'} = "ASC";
+	$args{'ORDER'} = "ASC";
     }
 
+    $self->{'order_clause'} = "";
+    if ( ($args{'ALIAS'}) and
+	 ($args{'FIELD'}) and
+	 ($args{'ORDER'}) ) {
+
+        $self->{'order_clause'} = "ORDER BY ";
+        $self->{'order_clause'} .= $args{'ALIAS'} . ".";
+        $self->{'order_clause'} .= $args{'FIELD'} . " ";
+        $self->{'order_clause'} .= $args{'ORDER'};
+    }
     $self->RedoSearch();
+}
+
+sub MultiOrderBy {
+    my $self = shift;
+    my @args = @_;
+    my $row;
+    my $clause;
+
+    foreach $row ( @args ) {
+        my %rowhash = ( ALIAS => 'main',
+			FIELD => undef,
+			ORDER => 'ASC',
+			%$row
+		      );
+        if ($rowhash{'ORDER'} =~ /^des/i) {
+	    $rowhash{'ORDER'} = "DESC";
+        }
+        else {
+	    $rowhash{'ORDER'} = "ASC";
+        }
+
+        if ( ($rowhash{'ALIAS'}) and
+	     ($rowhash{'FIELD'}) and
+             ($rowhash{'ORDER'}) ) {
+
+            $clause .= ($clause ? ", " : " ");
+            $clause .= $rowhash{'ALIAS'} . ".";
+            $clause .= $rowhash{'FIELD'} . " ";
+            $clause .= $rowhash{'ORDER'};
+        }
+    }
 
+    if ($clause) {
+	$self->{'order_clause'} = "ORDER BY" . $clause;
+    }
+    else {
+	$self->{'order_clause'} = "";
+    }
+    $self->RedoSearch();
 }
 
-# }}}
+# }}} 
 
 # {{{ sub _OrderClause
 
@@ -892,26 +939,10 @@
 sub _OrderClause {
     my $self = shift;
 
-    my $clause = "";
-
-    #If we don't have an order defined, set the defaults
-    unless ( defined $self->{'order_by_field'} ) {
-        $self->OrderBy();
+    unless ( defined $self->{'order_clause'} ) {
+	return "";
     }
-
-    if (     ( $self->{'order_by_field'} )
-         and ( $self->{'order_by_alias'} )
-         and ( $self->{'order_by_order'} ) ) {
-
-        $clause = "ORDER BY ";
-        $clause .= $self->{'order_by_alias'} . "."
-          if ( $self->{'order_by_alias'} );
-        $clause .= $self->{'order_by_field'};
-        $clause .= " " . $self->{'order_by_order'}
-          if ( $self->{'order_by_order'} );
-    }
-
-    return ($clause);
+    return ($self->{'order_clause'});
 }
 
 # }}}
