Domanda

I have 3 different lists with the same items in it. ( List )

When I use an icomparer to sort them on date, my c# form sorts them in each list en doesn't take itemsall together and sort it after that.

    private List<Blog> lijstPublicBlogs;
    private List<Blog> lijstRestrictedBlogs;
    private List<Blog> lijstPrivateBlogs;

Those 3 lists I got, and I want that the comparer sorts all the items from all lists together, instead of sorting them per each list...

This is that my comparer is doing (For example, sorting on date):

List 1

03-04-2013

05-04-2013

List 2

04-04-2013

06-04-2013

List 3

01-04-2013

02-04-2013

But what I want is, put when sorting all list items together and do this: 01-04-2013

02-04-2013

03-04-2013

04-04-2013

05-04-2013

06-04-2013

Anyone got a clue how i can solve this... I really appreaciate it!

What I want to do is: Putting all the list items (from the 3 lists) together and use iComparer on the items.

È stato utile?

Soluzione

Those 3 lists I got, and I want that the comparer sorts all the items from all lists together, instead of sorting them per each list...

I strongly recommend that instead of maintaining three separate lists, you create one list with a type which contains all three items. Then you can sort the single list, and it's likely to be easier to work with the related items anyway. Whenever you have multiple collections which are all kept in sync, consider creating a type to encapsulate all the related items, so you can then create a single collection of that type. You'll save yourself a lot of headaches.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top