Choosing sort again reverses the sort order
authoramwaterhouse <Andrew Waterhouse>
Tue, 14 Dec 2004 11:16:47 +0000 (11:16 +0000)
committeramwaterhouse <Andrew Waterhouse>
Tue, 14 Dec 2004 11:16:47 +0000 (11:16 +0000)
src/jalview/analysis/AlignmentSorter.java

index 3881266..64682c1 100755 (executable)
@@ -83,6 +83,7 @@ public class AlignmentSorter {
   }\r
 \r
   /**    */\r
+  static boolean sortIdAscending = true;\r
   public static void sortByID(AlignmentI align) {\r
     int nSeq = align.getHeight();\r
 \r
@@ -96,9 +97,15 @@ public class AlignmentSorter {
 \r
     QuickSort.sort(ids,seqs);\r
 \r
-    setReverseOrder(align,seqs);\r
+    if(sortIdAscending)\r
+      setReverseOrder(align,seqs);\r
+    else\r
+      setOrder(align, seqs);\r
+\r
+    sortIdAscending = !sortIdAscending;\r
   }\r
 \r
+  static boolean sortGroupAscending = true;\r
   public static void sortByGroup(AlignmentI align) {\r
     int    nSeq = align.getHeight();\r
     Vector groups = align.getGroups();\r
@@ -120,7 +127,12 @@ public class AlignmentSorter {
       }\r
     }\r
 \r
-    setOrder(align,seqs);\r
+    if(sortGroupAscending)\r
+      setOrder(align,seqs);\r
+    else\r
+      setReverseOrder( align, vectorToArray(seqs));\r
+\r
+    sortGroupAscending = ! sortGroupAscending;\r
   }\r
 \r
   private static SequenceI [] vectorToArray(Vector tmp) {\r
@@ -132,6 +144,7 @@ public class AlignmentSorter {
     return seqs;\r
   }\r
 \r
+  static boolean sortTreeAscending = true;\r
   public static void sortByTree(AlignmentI align, NJTree tree) {\r
     int    nSeq = align.getHeight();\r
 \r
@@ -146,7 +159,12 @@ public class AlignmentSorter {
       }\r
     }\r
 \r
-    setOrder(align,tmp);\r
+    if(sortTreeAscending)\r
+      setOrder(align,tmp);\r
+    else\r
+      setReverseOrder(align, vectorToArray(tmp));\r
+\r
+      sortTreeAscending = !sortTreeAscending;\r
   }\r
 \r
   private static void addStrays(AlignmentI align, Vector seqs) {\r