diff --git a/inc/media.php b/inc/media.php
index a182ecb33e7a07e5e2de8450432ec90d1085b26c..a9f6be7710816cee4d95034d538c3849a05fc063 100644
--- a/inc/media.php
+++ b/inc/media.php
@@ -1296,7 +1296,7 @@ function media_restore($image, $rev, $auth){
  * @author Kate Arzamastseva <pshns@ukr.net>
  * @triggers MEDIA_SEARCH
  */
-function media_searchlist($query,$ns,$auth=null,$fullscreen=false,$sort=''){
+function media_searchlist($query,$ns,$auth=null,$fullscreen=false,$sort='natural'){
     global $conf;
     global $lang;
 
@@ -1316,15 +1316,10 @@ function media_searchlist($query,$ns,$auth=null,$fullscreen=false,$sort=''){
                     $conf['mediadir'],
                     'search_media',
                     array('showmsg'=>false,'pattern'=>$pattern),
-                    $dir);
+                    $dir,
+                    1,
+                    $sort);
         }
-
-        $data = array();
-        foreach ($evdata['data'] as $k => $v) {
-            $data[$k] = ($sort == 'date') ? $v['mtime'] : $v['id'];
-        }
-        array_multisort($data, SORT_DESC, SORT_NUMERIC, $evdata['data']);
-
         $evt->advise_after();
         unset($evt);
     }
diff --git a/inc/template.php b/inc/template.php
index ca1c8d9d57d0e1d471e31623ec9520352167c763..c8520dc262961fb03d2763d01d78253c57d214db 100644
--- a/inc/template.php
+++ b/inc/template.php
@@ -1229,7 +1229,7 @@ function tpl_localeFN($id) {
  * @param bool $fromajax - set true when calling this function via ajax
  * @author Andreas Gohr <andi@splitbrain.org>
  */
-function tpl_mediaContent($fromajax = false) {
+function tpl_mediaContent($fromajax = false, $sort='natural') {
     global $IMG;
     global $AUTH;
     global $INUSE;
@@ -1259,7 +1259,7 @@ function tpl_mediaContent($fromajax = false) {
         if($do == 'filesinuse') {
             media_filesinuse($INUSE, $IMG);
         } elseif($do == 'filelist') {
-            media_filelist($NS, $AUTH, $JUMPTO);
+            media_filelist($NS, $AUTH, $JUMPTO,false,$sort);
         } elseif($do == 'searchlist') {
             media_searchlist($INPUT->str('q'), $NS, $AUTH);
         } else {
diff --git a/lib/exe/ajax.php b/lib/exe/ajax.php
index 9769503a753bd455af9bb63ed8bcf5c0738c7209..6e2011cd93520858085c9e0f4ace818f7e214d61 100644
--- a/lib/exe/ajax.php
+++ b/lib/exe/ajax.php
@@ -219,10 +219,11 @@ function ajax_medialist(){
     global $INPUT;
 
     $NS = cleanID($INPUT->post->str('ns'));
+    $sort = $INPUT->post->bool('recent') ? 'date' : 'natural';
     if ($INPUT->post->str('do') == 'media') {
         tpl_mediaFileList();
     } else {
-        tpl_mediaContent(true);
+        tpl_mediaContent(true, $sort);
     }
 }