Your challenge is to sort a string, but rather than by the normal alphabetical order (abc..xyz), you will be sorting strings by a specified alphabet.
You must write a program or function that takes two inputs: An alphabet A and an string S. Both will only contain lowercase English letters, and both will contain at least one character.
You must move letters in S so that the letter that appears first in A appears first, then whichever letter appears second in A, etc. There may be some letters in S that do not appear in A, these should be left at the end and not moved around relative to each other.
Test cases:
A S Result
axd haxuizzxaxduxha aaaxxxxdhuizzuh
a xyz xyz
abc dcba abcd
il nmiuplliu iillnmupu
asdf qwerty qwerty
Fewest bytes wins!