diff --git a/src/Logic/Utilities.cs b/src/Logic/Utilities.cs
index 05aab3f63..40498448c 100644
--- a/src/Logic/Utilities.cs
+++ b/src/Logic/Utilities.cs
@@ -2002,9 +2002,23 @@ namespace Nikse.SubtitleEdit.Logic
else
userWords.LoadXml("");
- XmlNode node = userWords.CreateElement("word");
- node.InnerText = word;
- userWords.DocumentElement.AppendChild(node);
+ var words = new List();
+ foreach (XmlNode node in userWords.DocumentElement.SelectNodes("word"))
+ {
+ string w = node.InnerText.Trim();
+ if (w.Length > 0)
+ words.Add(w);
+ }
+ words.Add(word);
+ words.Sort();
+
+ userWords.DocumentElement.RemoveAll();
+ foreach (string w in words)
+ {
+ XmlNode node = userWords.CreateElement("word");
+ node.InnerText = w;
+ userWords.DocumentElement.AppendChild(node);
+ }
userWords.Save(userWordsXmlFileName);
}
}