Re: Sorted Dictionary / List woes.
"Nassar, Anthony" <[email protected]> Tue, 13 Nov 2007 11:04:23 -0500
| Newsgroups | gmane.comp.windows.devel.dotnet.winforms |
|---|---|
| Message-ID | <[email protected]> |
Why not encapsulate the Dictionary<long, MessageInfo> in a class that
implements Idictionary<long, MessageInfo>, and delegate all the calls
that a dictionary would normally handle to that private instance
variable? Then add a method like this, to sort the MessageInfo values on
demand.
public class Class1 : IDictionary<long, MessageInfo>
{
public IEnumerable<MessageInfo> GetChronologically()
{
List<MessageInfo> sorted = new
List<MessageInfo>(this.Values);
sorted.Sort(
delegate(MessageInfo left, MessageInfo
right)
{
return
left._dateTime.CompareTo(right._dateTime);
});
return sorted;
}