Repository navigation
SortListByProperty: .NET 10, fixed benchmark, descending sort, honest tests - #2267
Open
vladimir-pecanac-main wants to merge 1 commit into
Conversation
… tests - Retarget both projects to net10.0; BenchmarkDotNet 0.15.8, MSTest 4.4.1 (one meta package replaces the adapter and framework), Microsoft.NET.Test.Sdk 18.10.1, coverlet.collector 10.1.0. - Benchmark: every invocation now sorts a fresh unsorted copy (IterationSetup), so the in-place rows no longer sort an already sorted list. The IComparable row sorts by Pages, so it is renamed SortByPagesIComparable and gets a like-for-like SortByPagesUsingLinq row, plus SortByPagesDescendingUsingLinq. Benchmarks move to their own SortBenchmarks class. - The multiple-properties test could not fail: the unsorted input was already in the expected order. The input order changes and a second test proves the result differs from the input and from an Author-only sort. - Descending sample: SortByPagesDescendingUsingLinq and the in-place Sort((x, y) => y.Pages.CompareTo(x.Pages)) form, with a test for each. - File-scoped namespaces, Random.Shared, target-typed new(), required properties and nullable parameters on the comparers (nine nullable warnings gone), unused benchmark variable dropped.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Updates collections-lists/SortListByProperty for the refreshed article "Sort a List of Objects by Property in C#" (https://code-maze.com/sort-list-by-object-property-dotnet/). Only this folder changes.
Packages (re-queried on NuGet 2026-10-04, newest stable):
Benchmark fix:
Tests:
Idioms: file-scoped namespaces, Random.Shared, target-typed new(), required properties, nullable comparer parameters.
Built and benchmarked on Windows 10 (10.0.19045), SDK 10.0.302, runtime .NET 10.0.10, BenchmarkDotNet 0.15.8.