Introduction
My grandpa is a fan of James Bond, but he is always unsure on how to rank his favourite actors. As such, he is always making lists, which is a lot of work. He asked me to produce a program that will make his life easier, but I do not have time for that, I have to work! So I will count on you guys.
Challenge
The challenge is simple. The input will consist of a list, in the following format:
<number> <space> <actor's name> <newline>
Your task is to sort them based on the number at the beginning of the line, starting from the last, and ending with the first. All numbers should be removed.
However, my grandpa sometimes makes mistakes. As such, you will need to validate the data. If one of the names on the list doesn't refer to one of the actors who played Bond, you need to discard it. In case of repetitions, repeats should be removed, and the name should maintain the lowest weight it was associated with (example #3).
There is no limit to how many lines there may be.
The output only needs to be a list of some sort, whether it is an array, a comma separated string, just values separated by spaces, or something else entirely, i.e.
Pierce Brosnan, Sean Connery, David Niven
A trailing newline or space is allowed.
Example Input and Output
Input:
1 Sean Connery
2 Emma Watson
5 Timothy Dalton
4 Roger Moore
3 Daniel Craig
Output:
Timothy Dalton, Roger Moore, Daniel Craig, Sean Connery
Input:
2 Timothy Dalton
4 George Lazenby
5 George Lazenby
3 Bob Simmons
Output:
George Lazenby, Bob Simmons, Timothy Dalton
Input:
3 Sean Connery
2 Pierce Brosnan
1 Sean Connery
Output:
Pierce Brosnan, Sean Connery
As this is a code golf, shortest code (in bytes) wins!
Appendix
List of actors who played the role of Bond:
- Barry Nelson
- Bob Simmons
- Sean Connery
- Roger Moore
- David Niven
- George Lazenby
- Timothy Dalton
- Pierce Brosnan
- Daniel Craig
echo Sean Connery
because everyone knows, there is only one bond \$\endgroup\$