【发布时间】:2021-05-02 07:50:38
【问题描述】:
我有一个列表列表,我想按照与另一个列表列表相同的顺序进行排序:
l1 = [['hello', 'test'], ['there', 'correct'], ['Elem3', 'yes']]
l2 = [['hello'], ['Elem3'], ['there']]
所以我想重新排列 l1 使其与 l2 的顺序相同。 (注意:这只是一个简单的测试用例。我正在处理的实际列表中有几个元素。
例如结果应该是:
l1 = [['hello', 'test'], ['Elem3', 'yes'], ['there', 'correct']]
使用python2(企业版)
【问题讨论】:
标签: python sorting python-2.x