HELP While the ListItem class implements the Comparable inte
HELP
While the ListItem class implements the Comparable interface, it currently doesn\'t sort the items at all. Modify the code so that it will sort the ListItemsfrom lowest to highest based on their valA values. IN JAVA PLEASE
Solution
Please let me know if you need more information:-
-------------------------------------------------------------------
public int compareTo (ListItem o) {
                 // TODO Auto-generated method stub
            return (this.valA < o.valA) ? -1 : ((this.valA ==o.valA) ? 0 : 1);
         }
This method will return -1 if it is actual value is less than passed value[new value]
 If both are equal then it will retun 0
 if not return 1
based on this we can sort all elements only if list item id type of array or linkedlist.
 so that we will be having collection of elements.
Let me know if you want me to implement in such a way that so that i can implement list in your program to sort elements.
Thanks

