Fast-Sort in CloudSys PHP Hiring Challenge

Given 26 alphabets in an order, sort the string based on the alphabetical order listed.
Input:

2
wcyuogmlrdfphitxjakqvzbnes
jcdokai
miruqopsxthzdcnvkfbglwayje
wgfsyvno

Output:

codijak
osnvfgwy

PHP Implementation: