diff options
author | Luke Bratch <l_bratch@yahoo.co.uk> | 2014-11-24 15:19:19 +0000 |
---|---|---|
committer | Luke Bratch <l_bratch@yahoo.co.uk> | 2014-11-24 15:19:19 +0000 |
commit | ff74d82b3399ab6b559fc9d2d8aba1695973c6b4 (patch) | |
tree | d2e8cf96f4770ea270a2509cdcd8c8e5153a8334 /index.php | |
parent | 49ed286d02358864508109b11bec536570561da2 (diff) |
Implement sorting by size
Diffstat (limited to 'index.php')
-rw-r--r-- | index.php | 17 |
1 files changed, 15 insertions, 2 deletions
@@ -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)) { |