Sort IList by DateTime

Hey all

it's me again 🙂 So I managed to understand Objects and how to use them and so I'm rewriting my current program.

I use the Google API to get the Events from an calendar and this works fine but unfortunately the API returns an IList<Events> with some properties and also an ( I guess it is ) IList<Items> list inside.

So the events as you can think are in the multid. IList<Items>. Unfortunately when I want to use this list it does not return the items sorted by the DateTime which is also an propertie of IList<Items>.

So I wanted to sort this IList by DateTime and the return it. Unfortunately I don't find a way to do this since the ways I found with .Sort and .OrderBy are not available.

So what I thought of is to create an multid. array and sort then or to create a new List and sort this but I'm pretty sure this is not the good way and there should be a better way.

In my mind the IList is a very good way to handle this data but I'm not sure how to sort it.

Sorry if this is something obvious or you can find it in the net, I couldn't or I could not identify the way to do it.

So I would think of an way to have something like.

IList<Events> request = Google.API.IList<Events> return request.Items.OrderBy(DateTime)

Of course the syntax is not good in any way but just to let you know how I would think this can work in theory 🙂

So if someone has an idea to sort this or if someone knows if you can handle the Google API for Calender Events in any better way please let me know. At the moment I have a real dirty solution for this, not to sort it but to use it.

For the Sort I don't have any code since I could not create anything working.

Best, Mike

by the0MIKE via /r/csharp

Leave a Reply