I have a order/lines collection. I need to sort the order.lines collection using the LineNumber property. I understand that CPersistentCollection doesn't support sorting and that i must subclass it but, could you give me some orientation on how to make it?
Googling about sorting i found a lot of information and code to sort any class, but the problem to use it was that this code only see CPersistentCollection and CPersistentObject classes but not my Order and Lines classes and of course, the property Lines doesn't exists on it.
All this code works like: Sort(array,"Property",SortOrder)
of course in order.lines the property LineNumber doesn't exists, i suppose this code expects a declaration of lines like Dim Lines() as Line.
I think that my only solution was to sort the cpersistentcollection directly but i need some help!!! How can i access to Linenumber property of the Lines included in Order.Lines???
TIA
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2005-04-06
Hi Homer111,
The solution that worked for me was to create a wrapper around CPersistentCollection by calling Arraylist.Adapter() and creating a IComparer class for the particular class that I needed. Then I used the Sort() method with the IComparer class, and it worked.
Dan
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have a order/lines collection. I need to sort the order.lines collection using the LineNumber property. I understand that CPersistentCollection doesn't support sorting and that i must subclass it but, could you give me some orientation on how to make it?
Googling about sorting i found a lot of information and code to sort any class, but the problem to use it was that this code only see CPersistentCollection and CPersistentObject classes but not my Order and Lines classes and of course, the property Lines doesn't exists on it.
All this code works like: Sort(array,"Property",SortOrder)
of course in order.lines the property LineNumber doesn't exists, i suppose this code expects a declaration of lines like Dim Lines() as Line.
I think that my only solution was to sort the cpersistentcollection directly but i need some help!!! How can i access to Linenumber property of the Lines included in Order.Lines???
TIA
Hi Homer111,
The solution that worked for me was to create a wrapper around CPersistentCollection by calling Arraylist.Adapter() and creating a IComparer class for the particular class that I needed. Then I used the Sort() method with the IComparer class, and it worked.
Dan