M
Manish Hatwalne
I am little brain-dead today. Having problems writing comparator that will
do comparison (for sorting) for multiple parameters.
Here is what I need to do - I have object MyObj with several fields. now I
need to sort a collection of such objects based on list of fields supplied.
So say if I want to sort MyObj collection based on fields "date" & "price" -
similar to SQL "...order by date, price" - how do I do this?
Or in other words, how do I write comparator for following method?
any pointers, help would be highly appreciated!
TIA,
- Manish
do comparison (for sorting) for multiple parameters.
Here is what I need to do - I have object MyObj with several fields. now I
need to sort a collection of such objects based on list of fields supplied.
So say if I want to sort MyObj collection based on fields "date" & "price" -
similar to SQL "...order by date, price" - how do I do this?
Or in other words, how do I write comparator for following method?
Code:
List sort(Collection<MyObj> objects, final List sortFields, final
List<Enum.ASC/DESC> ascDesc){
}
any pointers, help would be highly appreciated!
TIA,
- Manish