Results 1 to 4 of 4

Thread: Descending Sorted List

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2002
    Location
    Malaysia
    Posts
    345

    Descending Sorted List

    How can I have a Sorted List in Descending Order?
    Thanks.

  2. #2
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    Re: Descending Sorted List

    What kind of list?
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Descending Sorted List

    Firstly, let me point out what you should have done up to now. To start with, you should have checked the appropriate radio button when creating this thread so we know what version you're using. If you're using 1.x then we know that it's a regular SortedList. If it's 2.0 then we would assume that it's a generic SortedList (i.e. SortedList<TKey, TValue>), although you really should specify because you can use either.

    Before that though, you should have read the documentation for the class you're using. Assuming you are using a regular SortedList you would then have read this:
    The elements of a SortedList are sorted by the keys either according to a specific IComparer implementation specified when the SortedList is created or according to the IComparable implementation provided by the keys themselves. In either case, a SortedList does not allow duplicate keys.
    You now know that if you want to use other than default sorting you have to provide an IComparer when the collection is created. That means when invoking a constructor, so you should then have read the documentation for the SortedList constructor. That would give you descriptions and examples of providing an IComparer to sort the keys.

    You should have done all that already as a matter of course. You may still not know exactly how to declare the IComparer, but you should already know that that's what you need to do. The Help is there to help so you should ALWAYS read it first when you have a question.

    Now, I'm quite prepared to provide a code example for you but not until you specify whether you're using a regular SortedList or the generic variety.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2002
    Location
    Malaysia
    Posts
    345

    Re: Descending Sorted List

    Thanks.

    jmcilhinney, you are right, I should have done my homework.

    I am using the regular Sorted List.

    This did the trick for me.

    http://www.skystonesoftware.com/temp...E-6C84E2F71E22
    Thanks.

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