I have a collection of beans, and one of the entries in that collection I always want to appear at the top of the list regardless of what column the user sorts on. Take the following table
type make model Add New
Coupe Ford Mustang
Sedan Telsa Model S
Sedan Ford Taurus
Wagon Ford Flex
Wagon Subaru Outback
If I was to sort by make or sort the type in decending order, I still want the “Add New” entry to appear at the top of the list. I would guess that I would use an ItemSorter, but I am not sure how I would code it. Any help on this would be appreciated.
You should override the compareTo() method in your bean class to handle the “Add New” case the way you want it and then call the compareTo() method of the superclass for the other cases. This link should provide much of the needed information: