How can I use "Sorted List" on my object collection
Hello,
I need help to sort the collection.
Controller is returning me the collection of data. Before I bind to repeater control I would like to sort it. I thought of using Sorted List. But I need to know how can I use it in better way.
Code:
List<CurrentServices> currentCollection;
currentCollection = CurrentInfoController.GetServices();
I want to sort currentCollection now.
Kinldy let me know.
Many Thanks
Re: How can I use "Sorted List" on my object collection
Re: How can I use "Sorted List" on my object collection
Thanks harsh,
I will try it..
Quote:
Originally Posted by Harsh Gupta
Re: How can I use "Sorted List" on my object collection
Code:
ServiceCollection.Sort(delegate(Service informationOne, Service informationTwo)
{
return informationOne.DisplayName.CompareTo(informationTwo.DisplayName);
});
this is working for me. internally how it works is my question?
anybody?
Quote:
Originally Posted by CodeMaker
Thanks harsh,
I will try it..
Re: How can I use "Sorted List" on my object collection
You could use ILDASM to look at what it's doing internally but the basic mechanism is that the Sort method iterates through all of the items in the List, passing two items at a time as per the QuickSort algorithm.