Created
January 12, 2018 02:30
-
-
Save tschf/d5eb35ba39495e69a9990957dc2c4af3 to your computer and use it in GitHub Desktop.
.net ordering a list example
This file contains 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
List<SystemVersion> installedVersions = new List<SystemVersion>(); | |
installedVersions.Add(new SystemVersion("system17.1.123.1256")); | |
installedVersions.Add(new SystemVersion("system17.2.0.188.1159")); | |
installedVersions.Add(new SystemVersion("system4.2.123.1256")); | |
List<SystemVersion> sortedVersions = | |
installedVersions | |
.OrderByDescending(o=>o.BuildNumber.Major) | |
.ThenByDescending(o=>o.BuildNumber.Minor) | |
.ThenByDescending(o=>o.BuildNumber.MajorRevision) | |
.ThenByDescending(o=>o.BuildNumber.MinorRevision) | |
.ThenByDescending(o=>o.Patch) | |
.ToList(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment