Serial no. concordination

If the serial #s are in a chronological sequence, then you should print the first serial # through the last serial # with an indication that the serial #s are in chronological order. If there are multiple sequences of serial #s, then they should be listed in ranges as well; if there are individual serial #s that do not fall within a range, they should be printed individually. For example:

· One sequence of #s:

o CYCHC1G-0001 - CYCHC1G-0043

· Two sequences of #s:

o CYCHC1G-0001 - CYCHC1G-0043; CYCHC1G-0050 – CYCHC1G-0060

· Multiple sequences of #s and individual #s:

o CYCHC1G-0001 - CYCHC1G-0043; CYCHC1G-0050 – CYCHC1G-0060; CYCHC1G-0062; CYC-HC1G-0064; CYC-HC1G-0070 – CYCHC1G-0100

Please can any one suggest me logical looping using C/AL Code.