How can i sort ArrayList in java without using comparator.?
I have already used comparator and it work not properly for me, means data is not in particuler manner.
I have one array list that contain following properties...
getTotal(),
getID(),
getRank(),
getItemName(),
getFinalRank()
I have sotred this all this into one arraylist itemWiseDetails
now i want to make poi report and display all this details but according to rank of that itemName. ANd one more thing my rank is in String so when i Tried to sort based on this rank it take N/A data as a 0 rank so it displayed first then it display first rank , then second and go on ..
So, I want to sort this itemWiseDetails list without comparator
Thanks in advance,
I have implement Comparator like this way
public int compareTo(Object itemDetailVO)
{
if (!(itemDetailVOinstanceof ItemDetailVO)) throw new ClassCastException("AItemDetailVOobject expected.");
int otherItemRank = Integer.parseInt(((ItemDetailVO) itemDetailVO).getRank().toString());
return Integer.parseInt(this.trLotRank.toString())- otherBidderRank;
}