summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Bratch <l_bratch@yahoo.co.uk>2014-11-24 15:19:19 +0000
committerLuke Bratch <l_bratch@yahoo.co.uk>2014-11-24 15:19:19 +0000
commitff74d82b3399ab6b559fc9d2d8aba1695973c6b4 (patch)
treed2e8cf96f4770ea270a2509cdcd8c8e5153a8334
parent49ed286d02358864508109b11bec536570561da2 (diff)
Implement sorting by size
-rw-r--r--index.php17
1 files 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)) {