From ff74d82b3399ab6b559fc9d2d8aba1695973c6b4 Mon Sep 17 00:00:00 2001 From: Luke Bratch Date: Mon, 24 Nov 2014 15:19:19 +0000 Subject: Implement sorting by size --- index.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/index.php b/index.php index 8a56c8d..dd5026c 100644 --- a/index.php +++ b/index.php @@ -124,28 +124,41 @@ foreach ($files as $key=> $file) { } if (isset($sort)) { + // Sort by modified date if ($sort[0] == "M") { if ($sort[1] == "A") { ksort($new_array); } else { krsort($new_array); } + $ordered_array = $new_array; + // Sort by name } else if ($sort[0] == "N") { if ($sort[1] == "A") { asort($new_array); } else { arsort($new_array); } + $ordered_array = $new_array; + // Sort by size + } else if ($sort[0] == "S") { + if ($sort[1] == "A") { + asort($size_array); + } else { + arsort($size_array); + } + $ordered_array = $size_array; } } else { krsort($new_array); + $ordered_array = $new_array; } $listsize = 0; -while ($this_array = each($new_array)){ - $value = $this_array['value']; +while ($this_array = each($ordered_array)) { $key = $this_array['key']; + $value = $new_array[$key]; // Only show last X entries if requested if (isset($_GET['last']) && ($listsize > $_GET['last'] - 1)) { -- cgit v1.2.3