Index: /extensions/SmartAlbums/admin/album.php
===================================================================
--- /extensions/SmartAlbums/admin/album.php	(revision 27265)
+++ /extensions/SmartAlbums/admin/album.php	(revision 27266)
@@ -198,5 +198,21 @@
   'limit' => array(
     'name' => l10n('Max. number of photos'),
-    'options' => array(),
+    'options' => array(
+      ''                    => '-- ' . l10n('Default') . ' --',
+      'file ASC'            => l10n('File name, A &rarr; Z'),
+      'file DESC'           => l10n('File name, Z &rarr; A'),
+      'name ASC'            => l10n('Photo title, A &rarr; Z'),
+      'name DESC'           => l10n('Photo title, Z &rarr; A'),
+      'date_creation DESC'  => l10n('Date created, new &rarr; old'),
+      'date_creation ASC'   => l10n('Date created, old &rarr; new'),
+      'date_available DESC' => l10n('Date posted, new &rarr; old'),
+      'date_available ASC'  => l10n('Date posted, old &rarr; new'),
+      'rating_score DESC'   => l10n('Rating score, high &rarr; low'),
+      'rating_score ASC'    => l10n('Rating score, low &rarr; high'),
+      'hit DESC'            => l10n('Visits, high &rarr; low'),
+      'hit ASC'             => l10n('Visits, low &rarr; high'),
+      'id ASC'              => l10n('Numeric identifier, 1 &rarr; 9'),
+      'id DESC'             => l10n('Numeric identifier, 9 &rarr; 1'),
+      ),
     ),
   );
Index: /extensions/SmartAlbums/admin/template/album.tpl
===================================================================
--- /extensions/SmartAlbums/admin/template/album.tpl	(revision 27265)
+++ /extensions/SmartAlbums/admin/template/album.tpl	(revision 27266)
@@ -28,10 +28,13 @@
 
   $('#removeFilters').click(function() {
-    $('#filtersList li').each(function() {
-      $(this).remove();
-    });
+    $('#filtersList li:not(.empty)').remove();
+    $('#filtersList li.empty').show();
+
+    $("#addFilter option[value='limit']").removeAttr('disabled');
+    $("#addFilter option[value='level']").removeAttr('disabled');
 
     limit_level=0;
     level_count=0;
+
     return false;
   });
@@ -53,6 +56,8 @@
     count++;
 
-    var content = $("#filtersRepo #filter_"+type).html().replace(/iiii/g, count);
-    $block = $($.parseHTML(content)).appendTo("#filtersList");
+    $('#filtersList li.empty').hide();
+
+    var content = $("#filtersRepo #filter_"+type).html().replace(/iiii/g, count),
+        $block = $($.parseHTML(content)).appendTo("#filtersList");
 
     if (cond) {
@@ -97,6 +102,6 @@
 
   function select_dimensions($block, cond, value) {
-    console.log($block, cond, value);
     cond = cond || 'width';
+    var values;
 
     $block.find(">.filter-value>span").hide();
@@ -113,6 +118,6 @@
 
   function select_options($block, value) {
-    values = value.split(',');
-    for (j in values) {
+    var values = value.split(',');
+    for (var j in values) {
       $block.find(".filter-value option[value='"+ values[j] +"']").attr('selected', 'selected');
     }
@@ -124,5 +129,6 @@
     // remove filter
     $block.find(".removeFilter").click(function() {
-      type = $(this).next("input").val();
+      var type = $(this).next("input").val();
+
       if (type == 'limit') {
         limit_count=1;
@@ -242,7 +248,8 @@
 
 {if isset($new_smart)}
-function doBlink(obj,start,finish) {
+function doBlink(obj, start, finish) {
   jQuery(obj).fadeOut(400).fadeIn(400);
-  if(start!=finish) {
+
+  if (start != finish) {
     doBlink(obj,start+1,finish);
   }
@@ -271,6 +278,15 @@
   <fieldset id="SmartAlbum_options" style="margin-top:1em;{if !isset($filters) AND !isset($new_smart)}display:none;{/if}">
     <legend>{'Filters'|translate}</legend>
-
+    
+    <div>
+      <label><input type="radio" name="filters[0][value]" value="and" {if $filter_mode=='and'}checked="checked"{/if}> {'Photos must match all filters'|translate}</label>
+      <label><input type="radio" name="filters[0][value]" value="or" {if $filter_mode=='or'}checked="checked"{/if}> {'Photos must match at least one filter'|translate}</label>
+      <input type="hidden" name="filters[0][type]" value="mode">
+      <input type="hidden" name="filters[0][cond]" value="mode">
+    </div>
+
+    <fieldset>
     <ul id="filtersList">
+      <li class="empty">{'No filter'|translate}</li>
     {foreach from=$filters item=filter}{strip}
       {if $filter.type == 'tags'}
@@ -295,12 +311,5 @@
     {/strip}{/foreach}
     </ul>
-
-    <div>
-      <b>{'Mode'|translate} :</b>
-      <label><input type="radio" name="filters[0][value]" value="and" {if $filter_mode=='and'}checked="checked"{/if}> AND</label>
-      <label><input type="radio" name="filters[0][value]" value="or" {if $filter_mode=='or'}checked="checked"{/if}> OR</label>
-      <input type="hidden" name="filters[0][type]" value="mode">
-      <input type="hidden" name="filters[0][cond]" value="mode">
-    </div>
+    </fieldset>
 
     <p class="actionButtons">
@@ -325,5 +334,5 @@
 
   <p class="actionButtons" id="applyFilterBlock">
-    <input class="submit" type="submit" value="{'Submit'|translate}" name="submitFilters"/>
+    <input class="submit" type="submit" value="{'Save'|translate}" name="submitFilters"/>
     <input class="submit" type="submit" value="{'Count'|translate}" name="countImages" {if !isset($filters) AND !isset($new_smart)}style="display:none;"{/if}/>
     <span class="count_images_wrapper" {if !isset($filters) AND !isset($new_smart)}style="display:none;"{/if}><span class="count_image">{$IMAGE_COUNT}</span></span>
Index: /extensions/SmartAlbums/admin/template/filters.inc.tpl
===================================================================
--- /extensions/SmartAlbums/admin/template/filters.inc.tpl	(revision 27265)
+++ /extensions/SmartAlbums/admin/template/filters.inc.tpl	(revision 27266)
@@ -155,5 +155,5 @@
   <span class="filter-value">
     <input type="text" name="filters[iiii][value]" size="30"/>
-    <i>{'For "Is (not) in", separate each author by a comma'|translate}</i>
+    <br><i>{'For "Is (not) in", separate each author by a comma'|translate}</i>
   </span>
 </li>
@@ -176,5 +176,5 @@
 
   <span class="filter-value">
-    <input type="text" name="filters[iiii][value]" size="5"/>
+    <input type="number" name="filters[iiii][value]" size="5"/>
   </span>
 </li>
@@ -197,5 +197,5 @@
 
   <span class="filter-value">
-    <input type="text" name="filters[iiii][value]" size="5"/>
+    <input type="number" name="filters[iiii][value]" size="5"/>
   </span>
 </li>
@@ -231,8 +231,16 @@
 
   <input type="hidden" name="filters[iiii][cond]" value="limit"/>
-
-  <span class="filter-value">
-    <input type="text" name="filters[iiii][value]" size="5"/>
-  </span>
-</li>
-</div>
+  
+  <span class="filter-value" style="width:200px;">
+    <input type="number" name="filters[iiii][value]" size="5"/>
+  </span>
+  
+  <span class="filter-cond" style="width:auto;">
+    <b>{'Sort order'|translate}</b>
+    <select name="filters[iiii][cond]">
+      {html_options options=$options.limit.options}
+    </select>
+    <br><i>{'The sort order is only used in addition to the limit filter, it does not impact the final display order'|translate}</i>
+  </span>
+</li>
+</div>
Index: /extensions/SmartAlbums/include/functions.inc.php
===================================================================
--- /extensions/SmartAlbums/include/functions.inc.php	(revision 27265)
+++ /extensions/SmartAlbums/include/functions.inc.php	(revision 27266)
@@ -438,4 +438,5 @@
       {
         $limit = '0, '.$filter['value'];
+        if (!empty($filter['cond'])) $order_by = $filter['cond'];
         break;
       }
@@ -469,5 +470,5 @@
   $MainQuery.= '
   GROUP BY i.id
-  '.$conf['order_by'].'
+  '.(isset($order_by) ? "ORDER BY ".$order_by : $conf['order_by']).'
   '.(isset($limit) ? "LIMIT ".$limit : null).'
 ;';
@@ -622,5 +623,4 @@
       else
       {
-        $filter['cond'] = 'limit';
         $limit_is_set = true;
       }
Index: /extensions/SmartAlbums/language/en_UK/plugin.lang.php
===================================================================
--- /extensions/SmartAlbums/language/en_UK/plugin.lang.php	(revision 27265)
+++ /extensions/SmartAlbums/language/en_UK/plugin.lang.php	(revision 27266)
@@ -62,6 +62,9 @@
 $lang['Update albums every %s days'] = 'Update albums every %s days';
 $lang['Invalid number of days'] = 'Invalid number of days';
-$lang['Mode'] = 'Mode';
 $lang['Select albums...'] = 'Select albums...';
+$lang['Photos must match all filters'] = 'Photos must match all filters';
+$lang['Photos must match at least one filter'] = 'Photos must match at least one filter';
+$lang['No filter'] = 'No filter';
+$lang['The sort order is only used in addition to the limit filter, it does not impact the final display order'] = 'The sort order is only used in addition to the limit filter, it does not impact the final display order';
 
 ?>
Index: /extensions/SmartAlbums/language/fr_FR/plugin.lang.php
===================================================================
--- /extensions/SmartAlbums/language/fr_FR/plugin.lang.php	(revision 27265)
+++ /extensions/SmartAlbums/language/fr_FR/plugin.lang.php	(revision 27266)
@@ -43,5 +43,5 @@
 $lang['Limit must be an integer'] = 'La nombre d\'éléments doit être un entier';
 $lang['Rating score must be an integer'] = 'Le score doit être un entier';
-$lang['Regex is malformed'] = 'Regex malformée';
+$lang['Regex is malformed'] = 'Regex mal formée';
 $lang['You can\'t use more than one limit filter'] = 'Vous ne pouvez choisir qu\'une seule limite de nombre d\'éléments';
 $lang['You can\'t use more than one level filter'] = 'Vous ne pouvez choisir qu\'un seul niveau de confidentialité';
@@ -62,6 +62,9 @@
 $lang['Update albums every %s days'] = 'Mettre à jour les albums tous les %s jours';
 $lang['Invalid number of days'] = 'Nombre de jour invalide';
-$lang['Mode'] = 'Mode';
 $lang['Select albums...'] = 'Albums...';
+$lang['Photos must match all filters'] = 'Les photos doivent respecter tous les filtres';
+$lang['Photos must match at least one filter'] = 'Les photos doivent respecter au moins un filtre';
+$lang['No filter'] = 'Aucun filtre';
+$lang['The sort order is only used in addition to the limit filter, it does not impact the final display order'] = 'L\'ordre de tri est uniquement utilisé pour le nombre max. d\'éléments, il n\'impacte pas l\'ordre d\'affichage';
 
 ?>
Index: /extensions/SmartAlbums/maintain.inc.php
===================================================================
--- /extensions/SmartAlbums/maintain.inc.php	(revision 27265)
+++ /extensions/SmartAlbums/maintain.inc.php	(revision 27266)
@@ -62,5 +62,5 @@
   `category_id` smallint(5) unsigned NOT NULL,
   `type` varchar(16) NOT NULL,
-  `cond` varchar(16) NULL,
+  `cond` varchar(32) NULL,
   `value` text NULL,
   `updated` DATETIME NOT NULL DEFAULT "1970-01-01 00:00:00"
@@ -114,4 +114,8 @@
       }
     }
+    
+    // limit filter extended in 2.2.1
+    pwg_query('UPDATE `' . $this->table . '` SET cond = "" WHERE type = "limit" AND cond = "limit";');
+    pwg_query('ALTER TABLE `' . $this->table . '` CHANGE `cond` `cond` VARCHAR(32) NULL ;');
 
     $this->installed = true;
