Index: plugins/tags/_define.php
===================================================================
--- plugins/tags/_define.php	(revision 3731)
+++ plugins/tags/_define.php	(revision 3733)
@@ -16,5 +16,5 @@
     "Tags for posts",  // Description
     "Olivier Meunier", // Author
-    '1.4',             // Version
+    '1.5',             // Version
     array(
         'permissions' => 'usage,contentadmin',
Index: plugins/tags/_public.php
===================================================================
--- plugins/tags/_public.php	(revision 3731)
+++ plugins/tags/_public.php	(revision 3733)
@@ -94,7 +94,9 @@
         $limit = isset($attr['limit']) ? (integer) $attr['limit'] : 'null';
 
+        $combo = array('meta_id_lower', 'count', 'latest', 'oldest');
+
         $sortby = 'meta_id_lower';
-        if (isset($attr['sortby']) && $attr['sortby'] == 'count') {
-            $sortby = 'count';
+        if (isset($attr['sortby']) && in_array($attr['sortby'], $combo)) {
+            $sortby = strtolower($attr['sortby']);
         }
 
@@ -107,5 +109,7 @@
             "<?php\n" .
             "\$_ctx->meta = \$core->meta->computeMetaStats(\$core->meta->getMetadata(array('meta_type'=>'"
-            . $type . "','limit'=>" . $limit . "))); " .
+            . $type . "','limit'=>" . $limit .
+            ($sortby != 'meta_id_lower' ? ",'order'=>'" . $sortby . ' ' . ($order == 'asc' ? 'ASC' : 'DESC' ) : '') . "'" .
+            "))); " .
             "\$_ctx->meta->sort('" . $sortby . "','" . $order . "'); " .
             '?>';
@@ -138,7 +142,9 @@
         $type = isset($attr['type']) ? addslashes($attr['type']) : 'tag';
 
+        $combo = array('meta_id_lower', 'count', 'latest', 'oldest');
+
         $sortby = 'meta_id_lower';
-        if (isset($attr['sortby']) && $attr['sortby'] == 'count') {
-            $sortby = 'count';
+        if (isset($attr['sortby']) && in_array($attr['sortby'], $combo)) {
+            $sortby = strtolower($attr['sortby']);
         }
 
@@ -239,19 +245,8 @@
         }
 
-        $params = array('meta_type' => 'tag');
-
-        if ($w->limit !== '') {
-            $params['limit'] = abs((integer) $w->limit);
-        }
-
-        $rs = $core->meta->computeMetaStats(
-            $core->meta->getMetadata($params));
-
-        if ($rs->isEmpty()) {
-            return;
-        }
+        $combo = array('meta_id_lower', 'count', 'latest', 'oldest');
 
         $sort = $w->sortby;
-        if (!in_array($sort, array('meta_id_lower', 'count'))) {
+        if (!in_array($sort, $combo)) {
             $sort = 'meta_id_lower';
         }
@@ -262,5 +257,26 @@
         }
 
-        $rs->sort($sort, $order);
+        $params = array('meta_type' => 'tag');
+
+        if ($sort != 'meta_id_lower') {
+            // As optional limit may restrict result, we should set order (if not computed after)
+            $params['order'] = $sort . ' ' . ($order == 'asc' ? 'ASC' : 'DESC');
+        }
+
+        if ($w->limit !== '') {
+            $params['limit'] = abs((integer) $w->limit);
+        }
+
+        $rs = $core->meta->computeMetaStats(
+            $core->meta->getMetadata($params));
+
+        if ($rs->isEmpty()) {
+            return;
+        }
+
+        if ($sort == 'meta_id_lower') {
+            // Sort resulting recordset on cleaned id
+            $rs->sort($sort, $order);
+        }
 
         $res =
Index: plugins/tags/_widgets.php
===================================================================
--- plugins/tags/_widgets.php	(revision 3731)
+++ plugins/tags/_widgets.php	(revision 3733)
@@ -19,10 +19,15 @@
     public static function initWidgets($w)
     {
+        $combo = array(
+            __('Tag name')       => 'meta_id_lower',
+            __('Entries count')  => 'count',
+            __('Newest entry')   => 'latest',
+            __('Oldest entry')   => 'oldest'
+        );
+
         $w->create('tags', __('Tags'), array('tplTags', 'tagsWidget'), null, 'Tags cloud');
         $w->tags->setting('title', __('Title (optional)') . ' :', __('Tags'));
         $w->tags->setting('limit', __('Limit (empty means no limit):'), '20');
-        $w->tags->setting('sortby', __('Order by:'), 'meta_id_lower', 'combo',
-            array(__('Tag name') => 'meta_id_lower', __('Entries count') => 'count')
-        );
+        $w->tags->setting('sortby', __('Order by:'), 'meta_id_lower', 'combo', $combo);
         $w->tags->setting('orderby', __('Sort:'), 'asc', 'combo',
             array(__('Ascending') => 'asc', __('Descending') => 'desc')
