Results 1 to 5 of 5

Thread: How can I use "Sorted List" on my object collection

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2006
    Location
    Bangalore
    Posts
    172

    Smile 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

  2. #2
    Smitten by reality Harsh Gupta's Avatar
    Join Date
    Feb 2005
    Posts
    2,938

    Re: How can I use "Sorted List" on my object collection

    Show Appreciation. Rate Posts.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jan 2006
    Location
    Bangalore
    Posts
    172

    Re: How can I use "Sorted List" on my object collection

    Thanks harsh,

    I will try it..




    Quote Originally Posted by Harsh Gupta

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Jan 2006
    Location
    Bangalore
    Posts
    172

    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..

  5. #5
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width