merge-csv-lists: do not sort similar same words together
This commit is contained in:
parent
07430482d4
commit
f9faf4f8a4
|
@ -28,14 +28,8 @@ def unique_combined_list(*inputs):
|
||||||
if name not in final_list:
|
if name not in final_list:
|
||||||
final_list.append(name)
|
final_list.append(name)
|
||||||
|
|
||||||
# Flatten the list into individual words
|
# Sort the list
|
||||||
flattened_words = [word for name in combined_list for word in name.split()]
|
sorted_list = sorted(final_list)
|
||||||
|
|
||||||
# Sort the list based on the criteria discussed above
|
|
||||||
sorted_list = sorted(
|
|
||||||
final_list,
|
|
||||||
key=lambda x: (flattened_words.index(x.split()[0]), combined_list.index(x)),
|
|
||||||
)
|
|
||||||
|
|
||||||
# Convert the list back to a comma-separated string
|
# Convert the list back to a comma-separated string
|
||||||
output = ",".join(sorted_list)
|
output = ",".join(sorted_list)
|
||||||
|
|
Loading…
Reference in New Issue