I'd like to sort a `List` on element *counts* of `IGrouping`s.

And that's it, the list should ideally be the same. I would compromise with a new list, but then the elements should be the very same original objects, not copies (however shallow) and definitely not anonymous objects.

**Specifically:** We have an entity with many properties, and a list of objects of this type. We'd like to **(1)** group the objects by certain properties (name, address, ...) then **(2)** count the number of elements in each group. Finally we'd like to **(3)** reorder the list based on these counts by placing the elements that are part of the larger groups first.

**Note:** Our main issue is that we can't seem to find a way to keep a reference to the original objects in the elements of the groups. Indeed all we can select in the Linq query is the grouping key (or properties of the key) and nothing else is exposed by `IGrouping`. We can't figure out how to associate a group element with an element of the list either, short of looking at the data (and even then, we'd need the primary key, which we can't add to the grouping key or it would defeat the purpose of the grouping to begin with).
['https://Stackoverflow.com/questions/19517707', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2266481/']
```
var mySortedList = myList.GroupBy(x => x.Name).OrderByDescending(g => g.Count())
                       .SelectMany(x => x).ToList();

```
Almost no operation in .NET clones an object. Neither deeply nor shallowly. LINQ also does not clone the elements it processes. Therefore, a simple LINQ query will work:

```
var oldList = ...;
var newList = (from x in oldList
               group x by something into g
               orderby g.Count()
               from x in g //flatten the groups
               select x).ToList();

```

This code copies *references* to the original objects. If you believe otherwise, you are probably misinterpreting what you are seeing.