08-08-2011 04:07 AM
Please help me to short following String arry
How do I sort this like: jan2010,jan2011,feb2011,mar2012
thanks for advance(not to use string functions more )
08-08-2011 04:11 AM
08-08-2011 04:37 AM
08-08-2011 04:47 AM
08-08-2011 05:41 AM - edited 08-08-2011 08:03 AM
You can't sort these Strings correctly into date order, without interpreting the String values in some way. So you are going to have to write something that knows that jan2010 should be sorted like 012010, and feb2011 should be sorted like 022011. The easiest approach I suspect is to use SimpleSortingVector and create your own Comparator that converts the String to a value that can be compared.
Edit: Apologies, when I opened this, SImon had not replied, but clearly he did so between my opening and my posting, in fact a lot happened. So ignore my post. Content left in since following posts reference it.
08-08-2011 07:27 AM
08-08-2011 07:37 AM - edited 08-08-2011 07:39 AM
Look at the KeywordFilterDemo that is zipped with JDE samples for implementation/usage of Comparator. However, I don't think Comparator won't be handy to achieve what you want.