How can I change SortedList order?

K

Ken Varn

I am using the SortedList class to sort an array of items. I want to bind
the SortedList to a DataGrid, but I want the list to go in descending order.
Is there anyway to change the sort order in SortedList when databinding so
that I can reverse the sort order?



--
-----------------------------------
Ken Varn
Senior Software Engineer
Diebold Inc.

EmailID = varnk
Domain = Diebold.com
-----------------------------------
 
S

S.M. Altaf [MVP]

There is no native method to reverse the elements in a SortedList. You can
either copy over all the elements to an ArrayList and then apply a
..Reverse() and bind to a datagrid, ORRRRRR... you can pass a class that
implements IComparer in the constructor of the class which specifies how two
elements should be compared and added to the list. You can find
documentation on the IComparer interface here:
http://msdn.microsoft.com/library/d...frlrfsystemcollectionsicomparerclasstopic.asp

HTH
S.M. Altaf
[MVP - VB]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top