diff --git a/src/Umbraco.Web/Editors/DictionaryController.cs b/src/Umbraco.Web/Editors/DictionaryController.cs index 4679a01412..547abdabdf 100644 --- a/src/Umbraco.Web/Editors/DictionaryController.cs +++ b/src/Umbraco.Web/Editors/DictionaryController.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Net; using System.Net.Http; using System.Web.Http; @@ -194,7 +195,7 @@ namespace Umbraco.Web.Editors const int level = 0; - foreach (var dictionaryItem in Services.LocalizationService.GetRootDictionaryItems()) + foreach (var dictionaryItem in Services.LocalizationService.GetRootDictionaryItems().OrderBy(ItemSort())) { var item = Mapper.Map(dictionaryItem); item.Level = 0; @@ -220,8 +221,7 @@ namespace Umbraco.Web.Editors /// private void GetChildItemsForList(IDictionaryItem dictionaryItem, int level, List list) { - foreach (var childItem in Services.LocalizationService.GetDictionaryItemChildren( - dictionaryItem.Key)) + foreach (var childItem in Services.LocalizationService.GetDictionaryItemChildren(dictionaryItem.Key).OrderBy(ItemSort())) { var item = Mapper.Map(childItem); item.Level = level; @@ -230,5 +230,7 @@ namespace Umbraco.Web.Editors GetChildItemsForList(childItem, level + 1, list); } } + + private Func ItemSort() => item => item.ItemKey; } } diff --git a/src/Umbraco.Web/Trees/DictionaryTreeController.cs b/src/Umbraco.Web/Trees/DictionaryTreeController.cs index 2046bdbf05..0dfe31dae1 100644 --- a/src/Umbraco.Web/Trees/DictionaryTreeController.cs +++ b/src/Umbraco.Web/Trees/DictionaryTreeController.cs @@ -3,6 +3,7 @@ using System.Linq; using System.Net.Http.Formatting; using umbraco.BusinessLogic.Actions; using Umbraco.Core; +using Umbraco.Core.Models; using Umbraco.Core.Services; using Umbraco.Web.Models.Trees; using Umbraco.Web.WebApi.Filters; @@ -50,10 +51,12 @@ namespace Umbraco.Web.Trees var nodes = new TreeNodeCollection(); + Func ItemSort() => item => item.ItemKey; + if (id == Constants.System.Root.ToInvariantString()) { nodes.AddRange( - Services.LocalizationService.GetRootDictionaryItems().Select( + Services.LocalizationService.GetRootDictionaryItems().OrderBy(ItemSort()).Select( x => CreateTreeNode( x.Id.ToInvariantString(), id, @@ -69,7 +72,7 @@ namespace Umbraco.Web.Trees if (parentDictionary == null) return nodes; - nodes.AddRange(Services.LocalizationService.GetDictionaryItemChildren(parentDictionary.Key).ToList().OrderByDescending(item => item.Key).Select( + nodes.AddRange(Services.LocalizationService.GetDictionaryItemChildren(parentDictionary.Key).ToList().OrderBy(ItemSort()).Select( x => CreateTreeNode( x.Id.ToInvariantString(), id,