From 8e1c45e9817efbc35d50f899a7cc768f6bacf317 Mon Sep 17 00:00:00 2001 From: Morten Christensen Date: Wed, 29 May 2013 05:37:55 -0200 Subject: [PATCH] Updating Sort methods to skip items that hasn't been sorted --- src/Umbraco.Core/Services/ContentService.cs | 9 +++++++++ src/Umbraco.Core/Services/MediaService.cs | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/src/Umbraco.Core/Services/ContentService.cs b/src/Umbraco.Core/Services/ContentService.cs index 0068c2e72a..0f041fe484 100644 --- a/src/Umbraco.Core/Services/ContentService.cs +++ b/src/Umbraco.Core/Services/ContentService.cs @@ -1131,6 +1131,15 @@ namespace Umbraco.Core.Services int i = 0; foreach (var content in items) { + //If the current sort order equals that of the content + //we don't need to update it, so just increment the sort order + //and continue. + if (content.SortOrder == i) + { + i++; + continue; + } + content.SortOrder = i; content.WriterId = userId; i++; diff --git a/src/Umbraco.Core/Services/MediaService.cs b/src/Umbraco.Core/Services/MediaService.cs index 9f15f7f0cc..6bf14c1559 100644 --- a/src/Umbraco.Core/Services/MediaService.cs +++ b/src/Umbraco.Core/Services/MediaService.cs @@ -735,6 +735,15 @@ namespace Umbraco.Core.Services int i = 0; foreach (var media in items) { + //If the current sort order equals that of the media + //we don't need to update it, so just increment the sort order + //and continue. + if (media.SortOrder == i) + { + i++; + continue; + } + media.SortOrder = i; i++;