2

I tried collection.sort and hash maps but it is sorting it in dictionary order. this array is list of web-elements text.

Scenario : my application is providing these values in a sorted manner and i need to verify that.so i am picking these values in an array list....and further i tried .......using collection sort ...its not working

Array need to be sorted

[A01B, A01D41, A23G4, A41D19, A43B1, A43B1, A43B13, A43B13, A43B5, A43B5, A43B7, A43C1, A46B, A46B1, A46B15]

Expected Array

 [A01B,A01D41,A23G4,A41D19,A43B1,A43B1,A43B5,A43B5,A43B7,A43B13,A43B13,A43C1,A46B,A46B1,A46B15]
6
  • 1
    what have you tried so far? Commented Jul 13, 2018 at 7:37
  • That's because, alphanumerically, string like A43B13 is before A43B7, because of the 1 after the B (which is lower than the 7): you have to implement a custom comparator Commented Jul 13, 2018 at 7:41
  • Please post your solution so that we can check.. Commented Jul 13, 2018 at 7:45
  • Well, I have a solution that I will now have to post as a comment without the code formatting and syntax highlighting. See below. Commented Jul 13, 2018 at 8:30
  • @Stultuske : i tried this code --stackoverflow.com/questions/27169234/… but it is not working as desired -----using this code i am getting output :[A01B,A01D41,A23G4,A41D19,A43B1,A43B1,A43B13,A43B13,A43B5,A43B5,A43B7,A43C1,A46B,A46B1,A46B15] which is as similar to output using simply collection.sort() Commented Jul 13, 2018 at 16:44

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.