Index: trunk/src/org/openstreetmap/josm/tools/TextTagParser.java
===================================================================
--- trunk/src/org/openstreetmap/josm/tools/TextTagParser.java	(revision 16471)
+++ trunk/src/org/openstreetmap/josm/tools/TextTagParser.java	(revision 16472)
@@ -5,5 +5,5 @@
 import static org.openstreetmap.josm.tools.I18n.trn;
 
-import java.util.HashMap;
+import java.util.LinkedHashMap;
 import java.util.Map;
 import java.util.Map.Entry;
@@ -52,5 +52,5 @@
          String[] lines = text.split(splitRegex);
          Pattern p = Pattern.compile(tagRegex);
-         Map<String, String> tags = new HashMap<>();
+         Map<String, String> tags = new LinkedHashMap<>();
          String k;
          String v;
Index: trunk/test/unit/org/openstreetmap/josm/tools/TextTagParserTest.java
===================================================================
--- trunk/test/unit/org/openstreetmap/josm/tools/TextTagParserTest.java	(revision 16471)
+++ trunk/test/unit/org/openstreetmap/josm/tools/TextTagParserTest.java	(revision 16472)
@@ -4,6 +4,9 @@
 import static org.junit.Assert.assertEquals;
 
+import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
@@ -173,3 +176,14 @@
         assertEquals(expected, TextTagParser.readTagsFromText("name=Main street\nurl=https://example.com/?id=1"));
     }
+
+    /**
+     * Tests that the tags ordering is stable.
+     */
+    @Test
+    public void testStableOrder() {
+        List<String> expected = Arrays.asList("foo4", "foo3", "foo2", "foo1");
+        ArrayList<String> actual = new ArrayList<>(TextTagParser.readTagsByRegexp(
+                "foo4=bar4 foo3=bar3 foo2=bar2 foo1=bar1", " ", "(.*?)=(.*?)", true).keySet());
+        assertEquals(expected, actual);
+    }
 }
