JAL-2792 sort feature attributes for output, not for storage
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Fri, 1 Dec 2017 15:52:58 +0000 (15:52 +0000)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Fri, 1 Dec 2017 15:52:58 +0000 (15:52 +0000)
src/jalview/datamodel/SequenceFeature.java

index 8a6cb61..34565c6 100755 (executable)
@@ -30,6 +30,7 @@ import jalview.util.StringUtils;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Map.Entry;
+import java.util.SortedMap;
 import java.util.TreeMap;
 import java.util.Vector;
 
@@ -643,9 +644,13 @@ public class SequenceFeature implements FeatureLocationI
         {
           /*
            * expand values in a Map attribute across separate lines
+           * copy to a TreeMap for alphabetical ordering
            */
-          Map<?, ?> values = (Map<?, ?>) value;
-          for (Entry<?, ?> e : values.entrySet())
+          Map<String, Object> values = (Map<String, Object>) value;
+          SortedMap<String, Object> sm = new TreeMap<>(
+                  String.CASE_INSENSITIVE_ORDER);
+          sm.putAll(values);
+          for (Entry<?, ?> e : sm.entrySet())
           {
             sb.append(String.format(ROW_DATA, key, e.getKey().toString(), e
                     .getValue().toString()));