I've some lists with variable number of elements. Each list is sorted, but the sorting algorithm is not known. I would like to merge the lists into one big list which contains all lists in same order, without duplicates.
Example Input:
- XS,M,L,XL
- S,M,XXL
- XXS,XS,S,L
Expected Result:
- XXS,XS,S,M,L,XL,XXL
The expected result is obtained by matching up the input sequences in order to obtain a merged result that contains the elements of each input sequence in the correct order, like this:
XS M L XL
S M XXL
XXS XS S L
-------------------
XXS XS S M L XL XXL
The function should notify, if there are elements which have ambiguous positions. Here, it would be XXL (it could stay after M,L or XL) and I need to specify its position manually after XL (because here I know the sorting algorithm and can help). I thought about defining pairs of every two elements, each pair in order as in original list. From this one could build the complete list.
Here's what I would do: