]> gitweb.fperrin.net Git - GpsPrune.git/blobdiff - tim/prune/function/RearrangePhotosFunction.java
Version 13, August 2011
[GpsPrune.git] / tim / prune / function / RearrangePhotosFunction.java
index 7a408c04988da527ce5d8a67366cc1a2de783ea7..b8d9312de7dce3c1c349c466ec101b8fe72c3d56 100644 (file)
@@ -194,17 +194,21 @@ public class RearrangePhotosFunction extends GenericFunction
        private static void sortPhotos(DataPoint[] inPhotos, boolean inSortByFile)
        {
                Comparator<DataPoint> comparator = null;
-               if (inSortByFile) {
+               if (inSortByFile)
+               {
                        // sort by filename
                        comparator = new Comparator<DataPoint>() {
                                public int compare(DataPoint inP1, DataPoint inP2) {
                                        if (inP2 == null) return -1; // all nulls at end
                                        if (inP1 == null) return 1;
+                                       if (inP1.getPhoto().getFile() == null || inP2.getPhoto().getFile() == null)
+                                               return inP1.getPhoto().getName().compareTo(inP2.getPhoto().getName());
                                        return inP1.getPhoto().getFile().compareTo(inP2.getPhoto().getFile());
                                }
                        };
                }
-               else {
+               else
+               {
                        // sort by photo timestamp
                        comparator = new Comparator<DataPoint>() {
                                public int compare(DataPoint inP1, DataPoint inP2) {