Sorted

String İnput: 1, 2, 2A, 2B, 2C, 3, 3A, 4, 5, 6, 32C, 32D, 50, 51/1, 51/2, 60, 61, 62, 200-2E, 200-2F, 200-2G, 200-2H, 201C, 201/21P, 201/21R, 201/21S,300,300A,301-2A, 542/2K, 542/2L,583-1, 583-585D, 583-585E, 605, 605A, 605B,605C 800A.

Question is about merging consecutive values into a range. E.g.

**4,5,6 =[4-6] , 2A, 2B, 2C** are consecutive values, so range is

**2[A-C].** No other values can be in a range.

• General

pattern: number[chars][A-Z]

If chars is present, then they have to be equals() to be in a sequence. If the trailing letter is present, they have to be consecutive to have a sequence

A sequence is then abbreviated using: first + "-" + last

51/1, 52/1, 53/1 ==> not merged

51/1A, 51/1B, 51/1C ==> 51/1[A-C]

51/1A, 52/1B, 53/1C ==> [51-53]/1[A-C]

It should be listed as follows.

output:

1

2

2[A-C]

3

3A

[4-6]

32[C-D]

50

51/1

51/2

[60-62]

200-2[E-H]

201C

201/21[P-S]

300

300A

301-2A

542/2[K-L]

583-1

583-585[D-E]

605

605[A-C]

800A

output= merged: [1, 2, 2A, 2B, 2C, 3, 3A,

** [4-6],** 32C, 32D, 50, 51/1, 51/2,

**[60-62]**, 200-2E, 200-2F, 200-2G, 200-2H, 201C, 201/21P, 201/21R, 201/21S, 300,300A,301-2A,542/2K, 542/2L,583-1, 583-585D, 583-585E, 605, 605A, 605B,605C 800A]

I'm waiting for your help.thanks.