# -*- coding: utf-8 -*-
def sort_order(entity_set, content):
"""
Sort according to the order of appearance
"""
ent_ind_dic = {}
for ent in entity_set:
ent_ind_dic[ent] = content.index(ent)
ent_ind_dic_new = dict(sorted(ent_ind_dic.items(), key=lambda x: x[1]))
print(ent_ind_dic)
print(ent_ind_dic_new)
print(ent_ind_dic_new.keys())
print(','.join(ent_ind_dic_new.keys()))
entity_set_ = {'1', '2', '3'}
content_ = '343434312341233'
sort_order(entity_set_, content_)
python字典集合快速排序
最新推荐文章于 2022-03-18 22:54:49 发布