diff --git a/index.php b/index.php
index e130b19..7f263e0 100644
--- a/index.php
+++ b/index.php
@@ -82,8 +82,11 @@ if (isset($_GET['f'])) {
// Sort and Reverse Filelist
natcasesort($files);
-if ($sort == 1)
+if ($sort == 1) {
$files = array_reverse($files);
+} else {
+ $files = array_values($files);
+}
if (!empty($dirs))
$files = array_merge($dirs, $files);
diff --git a/tpl/gallery.html b/tpl/gallery.html
index 14d17d5..3140b4a 100644
--- a/tpl/gallery.html
+++ b/tpl/gallery.html
@@ -49,7 +49,12 @@
1
{% endif %}
- {{ $page }}
+
+ {% if ($sort == 1): %}
+ {{ $page }}
+ {% else: %}
+ {{ $page }}
+ {% endif %}
{% if ($page < $last_page): %}
{{ $last_page }}