I have 2 lists. One contains the names of components and the other has the names of the components and their description as a string. I need to sort the description list using the component list so they have the same order.
components = ['R500','R501','C500','C501','C502','R500']
description =['R500 "RES 1k 1% 0603"','R500 "RES 1k 1% 0603"','R508 "RES 9k 1% 06013"','R501 "RES 10k 1% 0604"','C500 "1uF 10% 0805"','C501 10uF 10% 0806','C502 "1nF 10% 0807"']
R508 should be discarded as it isn't in the components list.
C501 in the description list has deliberately been formatted different as the formatting is not always the same.
The output I expect is;
description = [
'R500 "RES 1k 1% 0603"',
'R501 "RES 10k 1% 0604"',
'C500 "1uF 10% 0805"',
'C501 "10uF 10% 0806"',
'C502 "1nF 10% 0807"',
'R500 "RES 1k 1% 0603",]