Well, you can probably remove the ToList call, which doesn't help you at all.
You can make the calling code easier:
var dictionary = allDays.Where(n => n.Value.IsRequested || n.Value.IsApproved) .ToDictionary(x => x.Key, x => x.Value); var mostDays = new SortedList<DateTime, CalendarDay>(dictionary);
... but this will lead to the creation of an intermediate Dictionary<,> , so it is hardly effective.
Another option is that you can write your own ToSortedList extension ToSortedList , for example.
public static SortedList<TKey, TValue> ToSortedList<TSource, TKey, TValue> (this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TValue> valueSelector) { // TODO: Argument validation var ret = new SortedList<TKey, TValue>(); foreach (var element in source) { ret.Add(keySelector(element), valueSelector(element)); } return ret; }
Then the calling code will be simple:
var mostDays = allDays.Where(n => n.Value.IsRequested || n.Value.IsApproved) .ToSortedList(x => x.Key, x => x.Value);
I suspect this should be effective enough, as it will always add values ββto the end of the list at build time.
(For full operation, you want to add overloads that accept custom key mappings, etc., see ToDictionary .)