First() on a Dictionary?
peterfoldi opened this issue · comments
Hi Scott,
I am sure time proved that this code works as expected but it looks strange for me:
installedVersions = installedVersions.OrderByDescending(p => p.Value.Major)
.ThenByDescending(p => p.Value.Minor)
.ThenByDescending(p => p.Value.Profile)
.ThenByDescending(p => p.Value.ServicePack ?? 0)
.ToDictionary(p => p.Key, p => p.Value);
if (installedVersions.Any())
{
return installedVersions.First().Value;
}
Calling First() on a Dictionary shouldn't be a deterministic way to get the largest element from a Dictionary, or do I miss something here?
The dictionary is created and ordered from a dictionary that is built from a string, version pair.