Index: trunk/src/org/openstreetmap/josm/data/osm/Tag.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/osm/Tag.java	(revision 5057)
+++ trunk/src/org/openstreetmap/josm/data/osm/Tag.java	(revision 5058)
@@ -79,16 +79,4 @@
     }
 
-    /**
-     * Normalizes the key and the value of the tag by
-     * <ul>
-     *   <li>removing leading and trailing white space</li>
-     * <ul>
-     *
-     */
-    public void normalize() {
-        key = key.trim();
-        value = value.trim();
-    }
-
     @Override
     public int hashCode() {
Index: trunk/src/org/openstreetmap/josm/data/osm/TagCollection.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/osm/TagCollection.java	(revision 5057)
+++ trunk/src/org/openstreetmap/josm/data/osm/TagCollection.java	(revision 5058)
@@ -7,12 +7,14 @@
 import java.util.Arrays;
 import java.util.Collection;
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
+import org.openstreetmap.josm.tools.Utils;
 
 /**
@@ -712,23 +714,23 @@
         // See #7201 combining ways screws up the order of ref tags
         Set<String> originalValues = getValues(key);
-        if (originalValues.size() == 1)
+        if (originalValues.size() == 1) {
             return originalValues.iterator().next();
-
-        StringBuilder buffer = new StringBuilder();
-        Set<String> valSet = new HashSet<String>();
-        for (String vs : originalValues) {
-            valSet.addAll(Arrays.asList(vs.split(";")));
-        }
-        List<String> values = new ArrayList<String>(valSet);
+        }
+
+        Set<String> values = new LinkedHashSet<String>();
+        Map<String, Collection<String>> originalSplitValues = new LinkedHashMap<String, Collection<String>>();
+        for (String v : originalValues) {
+            List<String> vs = Arrays.asList(v.split(";\\s*"));
+            originalSplitValues.put(v, vs);
+            values.addAll(vs);
+        }
         values.remove("");
-        Collections.sort(values);
-        Iterator<String> iter = values.iterator();
-        while (iter.hasNext()) {
-            buffer.append(iter.next());
-            if (iter.hasNext()) {
-                buffer.append(";");
-            }
-        }
-        return buffer.toString();
+        // try to retain an already existing key if it contains all needed values (remove this if it causes performance problems)
+        for (Entry<String, Collection<String>> i : originalSplitValues.entrySet()) {
+            if (i.getValue().containsAll(values)) {
+                return i.getKey();
+            }
+        }
+        return Utils.join(";", values);
     }
 
