Basically the idea is to use a Comparator. In the Comparator, the character portion of the Strings are seperated from the numeric portion. Then as Strings, the numeric portions are left padded with 0s to be of equal length. The Strings are then put back together and compared.
So, for example, when comparing L2 and L100, the Strings would become L002 and L100.
This code works under the premise that each String in the ArrayList will be composed of one or more characters followed by one or more digits.
[ March 23, 2006: Message edited by: Keith Lynn ] [ March 23, 2006: Message edited by: Keith Lynn ]
I recommend creating a java.util.Comparator (to be used in Collections.sort(List, Comparator)) which defines the sort order you need. Probably you will want to separate the first letter of each string from the rest of the strings. If the first letters are equal, convert the remaining parts of the strings to numbers using Integer.parseInt(), and use those values to determine which value comes first. Hope that helps...
"I'm not back." - Bill Harding, Twister
Joined: Feb 01, 2004
Thank you both Keith and Jim. This is exactly what I was after.