shanselman / SmallestDotNet

SmallestDotNet - SmallestDotNet.com is a single page site that does one thing. It tells you the smallest, easiest download you'd need to get the .NET Framework on your system.
MIT License
130 stars 64 forks source link

First() on a Dictionary? #36

Closed peterfoldi closed 11 years ago

peterfoldi commented 11 years ago

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?

msarchet commented 11 years ago

The dictionary is created and ordered from a dictionary that is built from a string, version pair.