Post-determined Array Sorting
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.
JavaScript (ES6), 87 bytes
(a,s)=>a.map(n=>[...s].sort().join``.replace([/[^a-z]/g,/[^A-Z]/g,/\D/g][n],``)).join``
If the input array gave the order, rather than the precedence, of the three ranges (this only makes a difference for [1, 2, 0]
and [2, 1, 0]
whose effects are swapped) then this would have worked for 80 bytes:
(a,s,o=c=>a[(c<'a')+(c<'A')])=>[...s].sort((a,b)=>o(a)-o(b)||(a>b)-(a<b)).join``
I misread the question and still got 7 upvotes with this. Feel free to remove your upvotes and give them to @CharlieWynn instead, who came up with the best correction to my approach.
(a,s)=>a.map(n=>s.replace([/[^a-z]/g,/[^A-Z]/g,/\D/g][n],``)).join``
Pyth, 17 16 15 bytes
s@RSz@L[GrG1`UT
Test suite.
[ array literal containing...
G the alphabet (lowercase)
rG1 the alphabet, converted to uppercase
`UT inspect-range-10, generating the range [0,10) and
stringifying it, resulting in a string that contains no
letters and all numbers (so equivalent to '0123456789' for
filtering)
this creates ['ab...z', 'AB...Z', '01...9']
@L map over first (implicit) input (the ordering array) and take
the nth element in this array for each item
this gives us ['01...9', 'ab...z', 'AB...Z']
Sz take another line of input as a string and sort it, and then...
@R map over intersection: filter the line of input over presence
in each element in the new array
this results in ['123', 'ac', 'B']
s concatenate all and implicitly output
Thanks to @FryAmTheEggman for a byte and @Jakube for another!