D
Doug Poland
Hello,
Is it possible to use a comparator, or other sorting technique, to sort
a collection has fields that are themselves collections, and, use fields
from the nested collection the sort criteria?
For example, I have an ArrayList (POList) of Purchase Order objects
(PO). Currently I use a comparator to sort based on fields of the
objects in POList that are not collections i.e., String, Date, etc.
However, one of the fields in POList is an ArrayList (LineItemsList) of
Line Item Details objects (LineItems). There may be zero, one, or many
LineItems objects in the POList.
Let's say a PO has a getCustomerName field and a LineItems has a
getDeliveryDate field. I'd like to sort the POList based on
getCustomerName from the PO object and getDeliveryDate from the many
LineItems objects.
I've been googling and have turned up nothing so far. Thanks for your help!
Is it possible to use a comparator, or other sorting technique, to sort
a collection has fields that are themselves collections, and, use fields
from the nested collection the sort criteria?
For example, I have an ArrayList (POList) of Purchase Order objects
(PO). Currently I use a comparator to sort based on fields of the
objects in POList that are not collections i.e., String, Date, etc.
However, one of the fields in POList is an ArrayList (LineItemsList) of
Line Item Details objects (LineItems). There may be zero, one, or many
LineItems objects in the POList.
Let's say a PO has a getCustomerName field and a LineItems has a
getDeliveryDate field. I'd like to sort the POList based on
getCustomerName from the PO object and getDeliveryDate from the many
LineItems objects.
I've been googling and have turned up nothing so far. Thanks for your help!