Skip to content

Commit a792eae

Browse files
committed
Remove custom Result class.
Instead of return the list in a acustom Result class, containing the list. We now return only the List itself, as the previous solution was creating unneccesary onverhead.
1 parent 96ec295 commit a792eae

File tree

4 files changed

+8
-21
lines changed

4 files changed

+8
-21
lines changed

KalmarKommun.Datalager.Sort.Tests/KalmarKommun.Datalager.Sort.Tests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ public void TestSortAscendingByParsedIntThenDescendingByText()
3434
Key = "season"
3535
};
3636

37-
var ret = Sort.SortAscendingByParsedIntThenDescendingByText(input, new System.Threading.CancellationToken());
37+
var SortedList = Sort.SortAscendingByParsedIntThenDescendingByText(input, new System.Threading.CancellationToken());
3838

39-
Assert.That(ret.SortedList, Is.EqualTo(new List<Dictionary<string, string>> {
39+
Assert.That(SortedList, Is.EqualTo(new List<Dictionary<string, string>> {
4040
new Dictionary<string, string> {
4141
{ "season", "spring-2022" }
4242
},

KalmarKommun.Datalager.Sort/Definition.cs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,4 @@ public class Parameters
2525
[DefaultValue("")]
2626
public string Key { get; set; }
2727
}
28-
29-
public class Result
30-
{
31-
/// <summary>
32-
/// Contains SortedList which is ListToSort, sorted by the provided Key.
33-
/// </summary>
34-
[DisplayFormat(DataFormatString = "Expression")]
35-
public List<Dictionary<string, string>> SortedList;
36-
}
3728
}
Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Collections.Generic;
23
using System.Linq;
34
using System.Text.RegularExpressions;
45
using System.Threading;
@@ -11,22 +12,17 @@ public static class Sort
1112
{
1213
/// <summary>
1314
/// Task for sorting a List of Dicitionaries, based on the values of a key from the Dictionaries.
14-
///
1515
/// Documentation: https://github.com/krukle/FrendsTask_KalmarKommun.Datalager.Sort
16-
///
1716
/// </summary>
1817
/// <param name="input">The List to sort, and which key's values to sort by</param>
1918
/// <param name="cancellationToken"></param>
20-
/// <returns>The sorted list of dictionaries.</returns>
21-
public static Result SortAscendingByParsedIntThenDescendingByText(Parameters input, CancellationToken cancellationToken)
19+
/// <returns> List<Dictionary<string, string>> </returns>
20+
public static List<Dictionary<string, string>> SortAscendingByParsedIntThenDescendingByText(Parameters input, CancellationToken cancellationToken)
2221
{
23-
return new Result
24-
{
25-
SortedList = input.ListToSort
22+
return input.ListToSort
2623
.OrderBy(x => Int32.Parse(Regex.Match(x[input.Key], @"\d+").Value))
2724
.ThenByDescending(x => x[input.Key])
28-
.ToList()
29-
};
25+
.ToList();
3026
}
3127
}
3228
}

KalmarKommun.Datalager.Sort/KalmarKommun.Datalager.Sort.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<IncludeSource>true</IncludeSource>
1010
<PackageTags>Frends</PackageTags>
1111
<GenerateDocumentationFile>true</GenerateDocumentationFile>
12-
<Version>0.0.3</Version>
12+
<Version>0.0.4</Version>
1313
</PropertyGroup>
1414

1515
<ItemGroup>

0 commit comments

Comments
 (0)