I have two lists, let\'s say:
keys1 = [\'A\', \'B\', \'C\', \'D\', \'E\', \'H\', \'I\']
keys2 = [\'A\', \'B\', \'E\', \'F\', \'G\', \'H\',
I suspect that you may be asking for a solution to the shortest common supersequence problem, which I believe is NP-hard in the general case of an arbitrary number of input sequences. I'm not aware of any libraries for solving this problem, so you might have to implement one by hand. Probably the quickest way to get to working code would be to take interjay's answer using difflib and then use reduce
to run it on an arbitrary number of lists (make sure to specify the empty list as the 3rd argument to reduce
).