Index: trunk/src/org/openstreetmap/josm/data/AutosaveTask.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/AutosaveTask.java	(revision 3838)
+++ trunk/src/org/openstreetmap/josm/data/AutosaveTask.java	(revision 3839)
@@ -7,5 +7,4 @@
 import java.io.IOException;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.Date;
 import java.util.Deque;
@@ -274,5 +273,5 @@
                     moveToDeletedLayersFolder(f);
                 }
-            }          
+            }
         });
     }
Index: trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPreset.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPreset.java	(revision 3838)
+++ trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPreset.java	(revision 3839)
@@ -11,5 +11,4 @@
 import java.awt.Image;
 import java.awt.Insets;
-import java.awt.Color;
 import java.awt.event.ActionEvent;
 import java.io.BufferedReader;
@@ -182,48 +181,48 @@
     }
 
-        protected static class PresetListEntry {
-            String value;
-            String display_value;
-            String short_description;
-
-            public String getListDisplay() {
-                if (value.equals(DIFFERENT))
-                    return "<b>"+DIFFERENT.replaceAll("<", "&lt;").replaceAll(">", "&gt;")+"</b>";
-
-                if (value.equals(""))
-                    return "&nbsp;";
-
-                StringBuilder res = new StringBuilder("<b>");
-                if (display_value != null) {
-                    res.append(display_value);
-                } else {
-                    res.append(value);
-                }
-                res.append("</b>");
-                if (short_description != null) {
-                    // wrap in table to restrict the text width
-                    res.append("<br><table><td width='232'>(").append(short_description).append(")</td></table>");
-                }
-                return res.toString();
-            }
-
-            public PresetListEntry(String value) {
-                this.value = value;
-                this.display_value = value;
-            }
-
-            public PresetListEntry(String value, String display_value) {
-                this.value = value;
-                this.display_value = display_value;
-            }
-
-            // toString is mainly used to initialize the Editor
-            @Override
-            public String toString() {
-                if (value.equals(DIFFERENT))
-                    return DIFFERENT;
-                return display_value.replaceAll("<.*>", ""); // remove additional markup, e.g. <br>
-            }
-        }
+    protected static class PresetListEntry {
+        String value;
+        String display_value;
+        String short_description;
+
+        public String getListDisplay() {
+            if (value.equals(DIFFERENT))
+                return "<b>"+DIFFERENT.replaceAll("<", "&lt;").replaceAll(">", "&gt;")+"</b>";
+
+            if (value.equals(""))
+                return "&nbsp;";
+
+            StringBuilder res = new StringBuilder("<b>");
+            if (display_value != null) {
+                res.append(display_value);
+            } else {
+                res.append(value);
+            }
+            res.append("</b>");
+            if (short_description != null) {
+                // wrap in table to restrict the text width
+                res.append("<br><table><td width='232'>(").append(short_description).append(")</td></table>");
+            }
+            return res.toString();
+        }
+
+        public PresetListEntry(String value) {
+            this.value = value;
+            this.display_value = value;
+        }
+
+        public PresetListEntry(String value, String display_value) {
+            this.value = value;
+            this.display_value = display_value;
+        }
+
+        // toString is mainly used to initialize the Editor
+        @Override
+        public String toString() {
+            if (value.equals(DIFFERENT))
+                return DIFFERENT;
+            return display_value.replaceAll("<.*>", ""); // remove additional markup, e.g. <br>
+        }
+    }
 
     public static class Text extends Item {
@@ -460,6 +459,6 @@
                 PresetListEntry e = new PresetListEntry(value_array[i]);
                 e.display_value = (locale_display_values == null)
-                        ? (values_context == null ? tr(display_array[i])
-                                : trc(values_context, display_array[i])) : display_array[i];
+                ? (values_context == null ? tr(display_array[i])
+                        : trc(values_context, display_array[i])) : display_array[i];
                 if (short_descriptions_array != null) {
                     e.short_description = locale_short_descriptions == null ? tr(short_descriptions_array[i])
@@ -633,9 +632,10 @@
                 int j = 0;
                 for (int i = 0; i < lm.getSize(); i++) {
-                    if (parts.contains((((PresetListEntry)lm.getElementAt(i)).value))) 
+                    if (parts.contains((((PresetListEntry)lm.getElementAt(i)).value))) {
                         intParts[j++]=i;
+                    }
                 }
                 setSelectedIndices(Arrays.copyOf(intParts, j));
-                // check if we have acutally managed to represent the full 
+                // check if we have acutally managed to represent the full
                 // value with our presets. if not, cop out; we will not offer
                 // a selection list that threatens to ruin the value.
@@ -647,6 +647,8 @@
             int[] si = getSelectedIndices();
             StringBuilder builder = new StringBuilder();
-            for (int i=0; i<si.length; i++) { 
-                if (i>0) builder.append(delimiter);
+            for (int i=0; i<si.length; i++) {
+                if (i>0) {
+                    builder.append(delimiter);
+                }
                 builder.append(((PresetListEntry)lm.getElementAt(si[i])).value);
             }
@@ -726,6 +728,6 @@
                 PresetListEntry e = new PresetListEntry(value_array[i]);
                 e.display_value = (locale_display_values == null)
-                        ? (values_context == null ? tr(display_array[i])
-                                : trc(values_context, display_array[i])) : display_array[i];
+                ? (values_context == null ? tr(display_array[i])
+                        : trc(values_context, display_array[i])) : display_array[i];
                 if (short_descriptions_array != null) {
                     e.short_description = locale_short_descriptions == null ? tr(short_descriptions_array[i])
Index: trunk/src/org/openstreetmap/josm/tools/PresetTextComparator.java
===================================================================
--- trunk/src/org/openstreetmap/josm/tools/PresetTextComparator.java	(revision 3838)
+++ trunk/src/org/openstreetmap/josm/tools/PresetTextComparator.java	(revision 3839)
@@ -7,8 +7,20 @@
 import javax.swing.JMenuItem;
 
+import org.openstreetmap.josm.Main;
+
 public class PresetTextComparator implements Comparator<JMenuItem>, Serializable {
-    //TODO add error checking and stuff
     public int compare(JMenuItem arg0, JMenuItem arg1) {
-        return arg0.getText().compareTo(arg1.getText());
+        if (Main.main.menu.presetSearchAction.equals(arg0.getAction()))
+            return -1;
+        else if (Main.main.menu.presetSearchAction.equals(arg0.getAction()))
+            return 1;
+        else if (arg0.getText() == arg1.getText())
+            return 0;
+        else if (arg0.getText() == null)
+            return -1;
+        else if (arg1.getText() == null)
+            return 1;
+        else
+            return arg0.getText().compareTo(arg1.getText());
     }
 
