Post-determined Array Sorting Input:


An array containing three integers: 0, 1 and 2 in any order (i.e. [2, 0, 1])
And a string of length >= 2 only containing alphabetic letters (both lower- and uppercase) and digits (i.e. a1B2c3)


Output:

Based on the array we sort and output the string.
How does this work?


The array indicates the order precedence of a-z, A-Z and 0-9, the first being 0; second being 1; and third being 2.
The individual characters of the string can then be ordered based on that.


Example:


Array: [2, 0, 1]
String: a1B2c3


Based on the array, we know our order precedence is 0-9a-zA-Z.
Based on that, we can convert and output the string: 123acB.

Challenge rules:


For the array you can choose to use 0-indexed or 1-indexed input, so [3, 1, 2] is also a valid input if you prefer to use 1-indexed arrays.
The string (both input and output) only contains valid characters: abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.
If your language doesn't support arrays (or if you choose to), you are free to use strings instead of arrays for the first parameter (i.e. 012, [0,1,2], etc.).


General rules:


This is code-golf, so shortest answer in bytes wins.
Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language.
Standard rules apply for your answer, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters, full programs. Your call.
Default Loopholes are forbidden.
If possible, please add a link with a test for your code.
Also, please add an explanation if necessary.


Test cases:

[2, 0, 1]  &amp;  a1B2c3             -&gt;   123acB
[2, 1, 0]  &amp;  aAaA909UuHWw9gh2   -&gt;   02999AAHUWaaghuw
[2, 1, 0]  &amp;  6Bx43              -&gt;   346Bx
[1, 0, 2]  &amp;  jfjf33g            -&gt;   ffgjj33
[0, 2, 1]  &amp;  AbC13              -&gt;   b13AC
[1, 2, 0]  &amp;  Qfl0l              -&gt;   Q0fll
[0, 1, 2]  &amp;  9870abcABC         -&gt;   abcABC0789
[0, 2, 1]  &amp;  test123            -&gt;   estt123
[2, 0, 1]  &amp;  WHAT               -&gt;   AHTW
[2, 0, 1]  &amp;  WhAt               -&gt;   htAW
[1, 0, 2]  &amp;  102BACbac          -&gt;   ABCabc012
Python 2, 67 66 bytes



lambda s,k:`sorted(s,key=lambda c:`k.index(3-ord(c)/32)`+c)`[2::5]


Test it on Ideone.