0

For example i have List with content: {1 5 2b 10 2a 3 7}, and i need sort it in alphabet order as: {1 2a 2b 3 5 7 10}. I tried with Comparator interface as:

Collections.sort(list);

But it returned array {1 10 2a 2b 3 5 7}. How i can do it in Java?

7
  • 1
    Are there any strings where there is no number in front? Commented Mar 31, 2015 at 14:22
  • 3
    Is this what you are looking for? Commented Mar 31, 2015 at 14:23
  • @laune, no, all strings have number in front Commented Mar 31, 2015 at 14:25
  • You tried implementing the Comparator interface? Show us the implementation then. The mistake must be in there. Commented Mar 31, 2015 at 14:27
  • See stackoverflow.com/questions/3552756/… for how to get the int part, then sort by that. Commented Mar 31, 2015 at 14:27

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.