How to simply convert an IEnumerable into IOrderedEnumerable in O(1)?

834 Views Asked by At

Is there a way to simply convert an IEnumerable into an IOrderedEnumerable in O(1)?
I've seem this question which is close to mine, but haven't found what I'm looking for. By simply, I mean to avoid creating a new class just for this casting purpose like it was done in Servy's solution in the question I referred to.

Here is a the scenario as why I need such thing.

public IOrderedEnumerable<Output> Sort(IEnumerable<ComplexObjs> objs)
{
    return objs.OrderByDescending(o => o.A)
              .ThenBy(o => o.B)
              .ThenBy(o => o.C)
              .SelectMany(o => o.Childs.Select(x => new Output(o, x)))
}

Note : Everything is linq to object, there is nothing connected to a database in this scenario.

0

There are 0 best solutions below