diff --git a/src/common/contacts.py b/src/common/contacts.py
index 51a29b3c2e462d3fac732db2246da4feba98d12b..8c2aca6ab26594f3b15e320706a4568a25e1d1c0 100644
--- a/src/common/contacts.py
+++ b/src/common/contacts.py
@@ -389,7 +389,7 @@ class Contacts:
 					return tag
 		return None
 
-	def add_metacontact(self, brother_account, brother_jid, account, jid):
+	def add_metacontact(self, brother_account, brother_jid, account, jid, order=None):
 		tag = self.get_metacontacts_tag(brother_account, brother_jid)
 		if not tag:
 			tag = self.get_new_metacontacts_tag(brother_jid)
@@ -406,8 +406,12 @@ class Contacts:
 		if tag not in self._metacontacts_tags[account]:
 			self._metacontacts_tags[account][tag] = [{'jid': jid, 'tag': tag}]
 		else:
-			self._metacontacts_tags[account][tag].append({'jid': jid,
-				'tag': tag})
+			if order:
+				self._metacontacts_tags[account][tag].append({'jid': jid,
+					'tag': tag, 'order': order})
+			else:
+				self._metacontacts_tags[account][tag].append({'jid': jid,
+					'tag': tag})
 		common.gajim.connections[account].store_metacontacts(
 			self._metacontacts_tags[account])
 
@@ -510,6 +514,10 @@ class Contacts:
 				return 1
 			if data1['order'] < data2['order']:
 				return -1
+		if 'order' in data1:
+			return 1
+		if 'order' in data2:
+			return -1
 		transport1 = common.gajim.get_transport_name_from_jid(jid1)
 		transport2 = common.gajim.get_transport_name_from_jid(jid2)
 		if transport2 and not transport1:
diff --git a/src/roster_window.py b/src/roster_window.py
index 0f354331c4dea8059bc51c4621c4d730976b206e..1bbd79b3240b6f6ec3acf5074ce72fb0f6c26a5a 100644
--- a/src/roster_window.py
+++ b/src/roster_window.py
@@ -3759,6 +3759,7 @@ class RosterWindow:
 				'So those information will not be saved on next reconnection.'))
 
 		def merge_contacts(is_checked=None):
+			contacts = 0
 			if is_checked is not None: # dialog has been shown
 				if is_checked: # user does not want to be asked again
 					gajim.config.set('confirm_metacontacts', 'no')
@@ -3771,6 +3772,16 @@ class RosterWindow:
 				c_dest.jid)
 			if dest_family:
 				self._remove_metacontact_family(dest_family, account_dest)
+				source_family = gajim.contacts.get_metacontacts_family(account_source, c_source.jid)
+				if dest_family == source_family:
+					n = contacts = len(dest_family)
+					for tag in source_family:
+						if tag['jid'] == c_source.jid:
+							tag['order'] = contacts
+							continue
+						if 'order' in tag:
+							n -= 1
+							tag['order'] = n
 			else:
 				self._remove_entity(c_dest, account_dest)
 
@@ -3806,7 +3817,7 @@ class RosterWindow:
 
 				_contact.groups = c_dest.groups[:]
 				gajim.contacts.add_metacontact(account_dest, c_dest.jid,
-					_account, _contact.jid)
+					_account, _contact.jid, contacts)
 				gajim.connections[account_source].update_contact(_contact.jid,
 					_contact.name, _contact.groups)