Index: src/org/openstreetmap/josm/actions/MergeNodesAction.java
===================================================================
--- src/org/openstreetmap/josm/actions/MergeNodesAction.java	(revision 2339)
+++ src/org/openstreetmap/josm/actions/MergeNodesAction.java	(working copy)
@@ -13,6 +13,7 @@
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashSet;
+import java.util.LinkedHashSet;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Set;
@@ -53,7 +54,7 @@
         if (!isEnabled())
             return;
         Collection<OsmPrimitive> selection = getCurrentDataSet().getSelected();
-        Set<Node> selectedNodes = OsmPrimitive.getFilteredSet(selection, Node.class);
+        LinkedHashSet<Node> selectedNodes = OsmPrimitive.getFilteredSet(selection, Node.class);
         if (selectedNodes.size() < 2) {
             JOptionPane.showMessageDialog(
                     Main.parent,
@@ -73,35 +74,19 @@
     }
 
     /**
-     * Selects a node out of a collection of candidate nodes. The selected
-     * node will become the target node the remaining nodes are merged to.
-     * 
+     * Find which node to merge into (i.e. which one will be left)
+     * The selected node will become the target node the remaining 
+     * nodes are merged to.
+     * It will be the last node in the list.
+     *
      * @param candidates the collection of candidate nodes
      * @return the selected target node
      */
-    public static Node selectTargetNode(Collection<Node> candidates) {
-        // Find which node to merge into (i.e. which one will be left)
-        // - this should be combined from two things:
-        //   1. It will be the first node in the list that has a
-        //      positive ID number, OR the first node.
-        //   2. It will be at the position of the first node in the
-        //      list.
-        //
-        // *However* - there is the problem that the selection list is
-        // _not_ in the order that the nodes were clicked on, meaning
-        // that the user doesn't know which node will be chosen (so
-        // (2) is not implemented yet.)  :-(
+    public static Node selectTargetNode(LinkedHashSet<Node> candidates) {
         Node targetNode = null;
-        for (Node n: candidates) {
-            if (!n.isNew()) {
-                targetNode = n;
-                break;
-            }
+        for (Node n : candidates) { // pick last one
+            targetNode = n;
         }
-        if (targetNode == null) {
-            // an arbitrary node
-            targetNode = candidates.iterator().next();
-        }
         return targetNode;
     }
 
Index: src/org/openstreetmap/josm/data/osm/OsmPrimitive.java
===================================================================
--- src/org/openstreetmap/josm/data/osm/OsmPrimitive.java	(revision 2339)
+++ src/org/openstreetmap/josm/data/osm/OsmPrimitive.java	(working copy)
@@ -10,6 +10,7 @@
 import java.util.Date;
 import java.util.HashMap;
 import java.util.HashSet;
+import java.util.LinkedHashSet;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Locale;
@@ -82,12 +83,13 @@
      * @param type the type to filter for
      * @return the sub-set of OSM primitives of type <code>type</code>
      */
-    static public <T extends OsmPrimitive>  Set<T> getFilteredSet(Collection<OsmPrimitive> set, Class<T> type) {
-        if (set == null) return Collections.emptySet();
-        HashSet<T> ret = new HashSet<T>();
-        for(OsmPrimitive p: set) {
-            if (type.isInstance(p)) {
-                ret.add(type.cast(p));
+    static public <T extends OsmPrimitive>  LinkedHashSet<T> getFilteredSet(Collection<OsmPrimitive> set, Class<T> type) {
+        LinkedHashSet<T> ret = new LinkedHashSet<T>();
+        if (set != null) {
+            for(OsmPrimitive p: set) {
+                if (type.isInstance(p)) {
+                    ret.add(type.cast(p));
+                }
             }
         }
         return ret;
