Index: /branches/release-39/lib/MT/ArchiveType/Yearly.pm
===================================================================
--- /branches/release-39/lib/MT/ArchiveType/Yearly.pm (revision 1741)
+++ /branches/release-39/lib/MT/ArchiveType/Yearly.pm (revision 2500)
@@ -103,5 +103,5 @@
             group => ["extract(year from authored_on)"],
             $args->{lastn} ? ( limit => $args->{lastn} ) : (),
-            sort => "extract(year from authored_on) $order"
+            sort => [ { column => "extract(year from authored_on)", desc => $order } ],
         }
     ) or return $ctx->error("Couldn't get yearly archive list");
Index: /branches/release-39/lib/MT/ArchiveType/AuthorMonthly.pm
===================================================================
--- /branches/release-39/lib/MT/ArchiveType/AuthorMonthly.pm (revision 2399)
+++ /branches/release-39/lib/MT/ArchiveType/AuthorMonthly.pm (revision 2500)
@@ -130,6 +130,8 @@
                     "extract(month from authored_on)"
                 ],
-                'sort' => "extract(year from authored_on) $order,
-                         extract(month from authored_on) $order"
+                'sort' => [
+                    { column => "extract(year from authored_on)", desc => $order },
+                    { column => "extract(month from authored_on)", desc => $order }
+                ],
             }
         ) or return $ctx->error("Couldn't get monthly archive list");
Index: /branches/release-39/lib/MT/ArchiveType/AuthorWeekly.pm
===================================================================
--- /branches/release-39/lib/MT/ArchiveType/AuthorWeekly.pm (revision 2399)
+++ /branches/release-39/lib/MT/ArchiveType/AuthorWeekly.pm (revision 2500)
@@ -130,5 +130,5 @@
                 ( $ts && $tsend ? ( range_incl => { authored_on => 1 } ) : () ),
                 group  => ["week_number"],
-                'sort' => "week_number $order"
+                'sort' => [ { column => "week_number", desc => $order } ]
             }
         ) or return $ctx->error("Couldn't get weekly archive list");
Index: /branches/release-39/lib/MT/ArchiveType/AuthorDaily.pm
===================================================================
--- /branches/release-39/lib/MT/ArchiveType/AuthorDaily.pm (revision 2401)
+++ /branches/release-39/lib/MT/ArchiveType/AuthorDaily.pm (revision 2500)
@@ -130,7 +130,9 @@
                     "extract(day from authored_on)"
                 ],
-                'sort' => "extract(year from authored_on) $order,
-                         extract(month from authored_on) $order,
-                         extract(day from authored_on) $order"
+                'sort' => [
+                    { column => 'extract(year from authored_on)', desc => $order },
+                    { column => 'extract(month from authored_on)', desc => $order },
+                    { column => 'extract(day from authored_on)', desc => $order }
+                ],
             }
         ) or return $ctx->error("Couldn't get monthly archive list");
Index: /branches/release-39/lib/MT/ArchiveType/AuthorYearly.pm
===================================================================
--- /branches/release-39/lib/MT/ArchiveType/AuthorYearly.pm (revision 2401)
+++ /branches/release-39/lib/MT/ArchiveType/AuthorYearly.pm (revision 2500)
@@ -123,5 +123,5 @@
             {
                 group  => ["extract(year from authored_on)"],
-                'sort' => "extract(year from authored_on) $order"
+                'sort' => [ { column => "extract(year from authored_on)", desc => $order } ]
             }
         ) or return $ctx->error("Couldn't get monthly archive list");
Index: /branches/release-39/lib/MT/ArchiveType/CategoryMonthly.pm
===================================================================
--- /branches/release-39/lib/MT/ArchiveType/CategoryMonthly.pm (revision 2399)
+++ /branches/release-39/lib/MT/ArchiveType/CategoryMonthly.pm (revision 2500)
@@ -127,6 +127,8 @@
                     "extract(month from authored_on)"
                 ],
-                sort => "extract(year from authored_on) $order,
-                              extract(month from authored_on) $order",
+                sort => [
+                    { column => "extract(year from authored_on)", desc => $order },
+                    { column => "extract(month from authored_on)", desc => $order },
+                ],
                 'join' =>
                   [ 'MT::Placement', 'entry_id', { category_id => $c->id } ]
Index: /branches/release-39/lib/MT/ArchiveType/Monthly.pm
===================================================================
--- /branches/release-39/lib/MT/ArchiveType/Monthly.pm (revision 1741)
+++ /branches/release-39/lib/MT/ArchiveType/Monthly.pm (revision 2500)
@@ -105,6 +105,8 @@
             ],
             $args->{lastn} ? ( limit => $args->{lastn} ) : (),
-            sort => "extract(year from authored_on) $order,
-                       extract(month from authored_on) $order"
+            sort => [
+                { column => "extract(year from authored_on)", desc => $order },
+                { column => "extract(month from authored_on)", desc => $order }
+            ],
         }
     ) or return $ctx->error("Couldn't get monthly archive list");
Index: /branches/release-39/lib/MT/ArchiveType/CategoryWeekly.pm
===================================================================
--- /branches/release-39/lib/MT/ArchiveType/CategoryWeekly.pm (revision 2399)
+++ /branches/release-39/lib/MT/ArchiveType/CategoryWeekly.pm (revision 2500)
@@ -128,5 +128,5 @@
                 ( $ts && $tsend ? ( range_incl => { authored_on => 1 } ) : () ),
                 group => ["week_number"],
-                sort  => "week_number $order",
+                sort  => [ { column => "week_number", desc => $order } ],
                 'join' =>
                   [ 'MT::Placement', 'entry_id', { category_id => $c->id } ]
Index: /branches/release-39/lib/MT/ArchiveType/CategoryDaily.pm
===================================================================
--- /branches/release-39/lib/MT/ArchiveType/CategoryDaily.pm (revision 2399)
+++ /branches/release-39/lib/MT/ArchiveType/CategoryDaily.pm (revision 2500)
@@ -127,7 +127,9 @@
                     "extract(day from authored_on)"
                 ],
-                sort => "extract(year from authored_on) $order,
-                              extract(month from authored_on) $order,
-                              extract(day from authored_on) $order",
+                sort => [
+                    { column => "extract(year from authored_on)", desc => $order },
+                    { column => "extract(month from authored_on)", desc => $order },
+                    { column => "extract(day from authored_on)", desc => $order },
+                ],
                 'join' =>
                   [ 'MT::Placement', 'entry_id', { category_id => $c->id } ]
Index: /branches/release-39/lib/MT/ArchiveType/Weekly.pm
===================================================================
--- /branches/release-39/lib/MT/ArchiveType/Weekly.pm (revision 1741)
+++ /branches/release-39/lib/MT/ArchiveType/Weekly.pm (revision 2500)
@@ -101,5 +101,5 @@
             group => [ "week_number" ],
             $args->{lastn} ? ( limit => $args->{lastn} ) : (),
-            sort => "week_number $order"
+            sort => [ { column => "week_number", desc => $order } ],
         }
     ) or return $ctx->error("Couldn't get weekly archive list");
Index: /branches/release-39/lib/MT/ArchiveType/Daily.pm
===================================================================
--- /branches/release-39/lib/MT/ArchiveType/Daily.pm (revision 1741)
+++ /branches/release-39/lib/MT/ArchiveType/Daily.pm (revision 2500)
@@ -103,7 +103,9 @@
             ],
             $args->{lastn} ? ( limit => $args->{lastn} ) : (),
-            sort => "extract(year from authored_on) $order,
-                        extract(month from authored_on) $order,
-                        extract(day from authored_on) $order"
+            sort => [
+                { column => "extract(year from authored_on)", desc => $order },
+                { column => "extract(month from authored_on)", desc => $order },
+                { column => "extract(day from authored_on)", desc => $order }
+            ],
         }
     ) or return $ctx->error("Couldn't get daily archive list");
Index: /branches/release-39/lib/MT/ArchiveType/CategoryYearly.pm
===================================================================
--- /branches/release-39/lib/MT/ArchiveType/CategoryYearly.pm (revision 2399)
+++ /branches/release-39/lib/MT/ArchiveType/CategoryYearly.pm (revision 2500)
@@ -120,5 +120,5 @@
             {
                 group => ["extract(year from authored_on)"],
-                sort  => "extract(year from authored_on) $order",
+                sort  => [ { column => "extract(year from authored_on)", desc => $order } ],
                 'join' =>
                   [ 'MT::Placement', 'entry_id', { category_id => $c->id } ]
Index: /branches/release-39/lib/MT/Object.pm
===================================================================
--- /branches/release-39/lib/MT/Object.pm (revision 2483)
+++ /branches/release-39/lib/MT/Object.pm (revision 2500)
@@ -1781,5 +1781,5 @@
 
     sort => [
-        { column => "column_1", desc => "descend" },
+        { column => "column_1", desc => "DESC" },
         { column => "column_2", }   # default direction is 'ascend'
     ]
Index: /branches/release-39/lib/MT/ObjectDriver/Driver/DBI.pm
===================================================================
--- /branches/release-39/lib/MT/ObjectDriver/Driver/DBI.pm (revision 2475)
+++ /branches/release-39/lib/MT/ObjectDriver/Driver/DBI.pm (revision 2500)
@@ -137,4 +137,11 @@
     my $order = delete $args->{sort};
     my $direction = delete $args->{direction};
+    if ( $order =~ /\sdesc|asc/i ) {
+        my @new_order;
+        while ($order =~ /(?:\s*([\w\s\(\)]+?)\s(desc|asc))/ig) {
+            push @new_order, { column => $1, desc => $2 };
+        }
+        $order = \@new_order if @new_order;
+    }
     my $limit = exists $args->{limit} ? delete $args->{limit} : undef;
     my $offset = exists $args->{offset} ? delete $args->{offset} : undef;
Index: /branches/release-39/t/driver-tests.pl
===================================================================
--- /branches/release-39/t/driver-tests.pl (revision 2475)
+++ /branches/release-39/t/driver-tests.pl (revision 2500)
@@ -33,5 +33,5 @@
 }
 
-plan tests => 184;
+plan tests => 197;
 
 package Zot;
@@ -400,10 +400,10 @@
 sleep(2);  ## Sleep to ensure created_on timestamps are unique
 
+# legacy way of specifying sort direction
 my $cgb_iter = Bar->count_group_by({
         status => '0',
     }, {
         group => [ 'foo_id' ],
-        sort => 'foo_id',
-        direction => 'descend',
+        sort => 'foo_id desc',
     });
 my ($count, $bfid, $month);
@@ -417,15 +417,45 @@
 ok(!$cgb_iter->(), 'no $iter');
 
-$cgb_iter = Bar->count_group_by(undef, {
+# new way of specifying sort direction
+my $cgb_iter2 = Bar->count_group_by({
+        status => '0',
+    }, {
+        group => [ 'foo_id' ],
+        sort => 'foo_id',
+        direction => 'descend'
+    });
+
+isa_ok($cgb_iter2, 'CODE');
+ok(($count, $bfid) = $cgb_iter2->(), 'set');
+is($bfid, $bar[1]->id, 'id');
+is($count, 1, 'count4');
+ok(($count, $bfid) = $cgb_iter2->(), 'set');
+is($bfid, $bar[0]->id, 'id');
+is($count, 1, 'count5');
+ok(!$cgb_iter2->(), 'no $iter');
+
+# legacy way of specifying sort direction
+my $cgb_iter3 = Bar->count_group_by(undef, {
         group => [ 'extract(month from created_on)' ],
-        sort => 'extract(month from created_on)',
-        direction => 'descend',
+        sort => 'extract(month from created_on) desc',
     });
-isa_ok($cgb_iter, 'CODE');
-ok(($count, $month) = $cgb_iter->(), 'set');
+isa_ok($cgb_iter3, 'CODE');
+ok(($count, $month) = $cgb_iter3->(), 'set');
 use POSIX qw(strftime);
 is(int($month), int(strftime("%m", localtime)), 'month');
 is($count, 3, 'count6');
-ok(!$cgb_iter->(), 'no $iter');
+ok(!$cgb_iter3->(), 'no $iter');
+
+# new way of specifying sort direction
+my $cgb_iter4 = Bar->count_group_by(undef, {
+        group => [ 'extract(month from created_on)' ],
+        sort => [{ column => 'extract(month from created_on)',
+            desc => 'desc' }]
+    });
+isa_ok($cgb_iter4, 'CODE');
+ok(($count, $month) = $cgb_iter4->(), 'set');
+is(int($month), int(strftime("%m", localtime)), 'month');
+is($count, 3, 'count6');
+ok(!$cgb_iter4->(), 'no $iter');
 
 ## Get a count of all Foo objects in order of most recently
