So, If I would test it with gap=2, your function would fail? What happens if I change the media length?

Hmm, the whole gap-business could have lead to the introduction of a third calling parameter CD_Sorter(SongList, MediaLength, Gap) but that's too late now.
_________________________
There are two types of vessels, submarines and targets.