I am looking for a way to sort a list in order of appearance in another string, so that the the follow code
thelist = ["a", "b", "c"]
thestring = "b c a"
will be able to be sorted into
["b", "c", "a"]
as that is the order that each of the list objects appear in the string.
How would I go about achieving this? Would it be possible to use the sorted function with certain param to easily achieve this or something else? Thanks.
thestring.split(), instead of sortingthelist?.sort(key=lambda c: thestring.index(c)), but that won't deal with repeats nicelythelist? Or repeats inthestring? In which case what position wins?