Skip to content

Instantly share code, notes, and snippets.

@tschf
Created January 12, 2018 02:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tschf/d5eb35ba39495e69a9990957dc2c4af3 to your computer and use it in GitHub Desktop.
Save tschf/d5eb35ba39495e69a9990957dc2c4af3 to your computer and use it in GitHub Desktop.
.net ordering a list example
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