As titled.
We all know if we want a class to be comparable and use in sorting i.e DataGrid, we will implement IComparable.
But for IEnumerable how can I do that?
I have a collection of a IEnumerable, we want to compare each IEnumerable to each other and do a sorting.
So say a collection List<IEnumerable<char>>
that contains:
IEnumerable<char> EnumableA
contains: "d", "e", "f"
IEnumerable<char> EnumableB
contains: "d", "e", "c"
If we bind the collection List<IEnumerable<char>>
to a DataGrid,
when we sort them in acs order, the order will be EnumableB
1st, then EnumableA
the 2nd.
I do think of solution such as store the EnumableA
into an object whichs implment IComparable
, but then this would require to create another collection of objects, which will be expensive.
So is it possible or anyway to APPEND a IComparable
interface and my sorting implmentation to the IEnuerable<char>
so it will be sortable?
No comments:
Post a Comment