How can I change SortedList order?

  • Thread starter Thread starter Ken Varn
  • Start date Start date
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
-----------------------------------
 
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]
 
Back
Top