[Solved] Python sort list by algorithm [closed]


Data = [
    '<td>1</td>', '<td>2</td>', '<td>3</td>', '<td>4</td>',
    '<td>A</td>', '<td>B</td>', '<td>C</td>', '<td>D</td>',
    '<td>I</td>', '<td>II</td>', '<td>III</td>', '<td>IV</td>',
]

lists, result = [], []
for i in range(0, len(Data), 4):
    lists.append(Data[i:i+4])

for currentList in zip(*lists):
    result += list(currentList)
print result

Output

['<td>1</td>', '<td>A</td>', '<td>I</td>',
 '<td>2</td>', '<td>B</td>', '<td>II</td>',
 '<td>3</td>', '<td>C</td>', '<td>III</td>',
 '<td>4</td>', '<td>D</td>', '<td>IV</td>']

solved Python sort list by algorithm [closed]