# HG changeset patch # User Matti Hamalainen # Date 1461429391 -10800 # Node ID f2c21a8b90716ef425556b9319e4a1eb74e7da53 # Parent 8cf743c7ea230bf50862ad5a66628aae75bb6315 Sort images in a folder by their capture timestamp. diff -r 8cf743c7ea23 -r f2c21a8b9071 mgtool.php --- a/mgtool.php Sun Apr 17 13:59:39 2016 +0300 +++ b/mgtool.php Sat Apr 23 19:36:31 2016 +0300 @@ -327,6 +327,15 @@ } +function mgSortFunc($a, $b) +{ + if (isset($a["datetime"]) && isset($b["datetime"])) + return strcmp($b["datetime"], $a["datetime"]); + else + return 0; +} + + function mgWriteGalleryCache($cacheFilename, &$gallery, &$entries, &$parentEntry) { // Store gallery cache for this directory @@ -343,7 +352,8 @@ else $albums[$ename] = &$edata; } - ksort($images); + + uasort($images, "mgSortFunc"); ksort($albums); // Choose gallery album image