g | x | w | all
Bytes Lang Time Link
010APLDyalog Unicode240925T075554Zakamayu
014K ngn/k240925T072158Zakamayu
007Jelly240923T011922ZUnrelate
006Nekomata240924T070755Zalephalp
045Python + NumPy240923T070826ZAlbert.L
010Uiua240923T214005Znyxbird
110Python240923T042739ZUnrelate
113Python3240923T015712ZAjax1234
016Charcoal240923T045516ZNeil

APL(Dyalog Unicode), 22 10 bytes SBCS

Same idea as @Albert.Lang's.

∊⊣⍉2⍨¨⍤⊣⍴⊢

Try it on APLgolf!

Try it on APLgolf! 22bytes

BQN, 8 bytes

⥊⊣⍉2˙¨⊸⥊

Try it on BQNPAD

K (ngn/k), 14 bytes

Naive implementation. It takes \$\sigma\$ as a 0-indexed premutation vector.

{y@2/(2\!#y)x}

Try it online!

Jelly, 7 bytes

UŒPṬỤỤị

Try it online!

Port of alephalpha's Nekomata answer.

U          Reverse p,
 ŒP        shortest-first powerset,
   Ṭ       untruth (surprised this vectorizes!),
    ỤỤ     double grade up (convert to permutation),
      ị    index into s.

Jelly, 9 8 bytes

ịⱮL2ṗɗỤị

Try it online!

Pretty naive implementation. Takes a 1-indexed permutation list \$[\sigma(1), ..., \sigma(n)]\$ on the left, and the string \$s\$ on the right.

   2ṗ       Raise [1, 2] to the Cartesian power of
  L         the length of the permutation (= n),
ịⱮ   ɗ      and index the permutation into each result.
      Ụ     Grade that up (argsort),
       ị    and index into s.

Nekomata, 6 bytes

↔SĦaõ@

Attempt This Online!

Takes the permutation as a 0-indexed list, e.g., [1,2,0] for \$\begin{pmatrix}0&1&2\\1&2&0\end{pmatrix}\$. Takes the binary string as a list of integers, e.g., [1,1,0,1,0,0,1,0] for 11010010.

↔SĦaõ@         Take [1,2,0] [1,1,0,1,0,0,1,0] as an example
↔           Reverse
                -> [0,2,1]
 S          Find a subset
                -> [] [0] [2] [0,2] [1] [0,1] [2,1] [0,2,1]
  Ħ         Histogram
                -> [] [1] [0,0,1] [1,0,1] [0,1] [1,1] [0,1,1] [1,1,1]
   a        All possible values
                -> [[],[1],[0,0,1],[1,0,1],[0,1],[1,1],[0,1,1],[1,1,1]]
    õ       Ordering
                -> [0,2,4,6,1,3,5,7]
     @      Index into the second input
                -> [1,0,0,1,1,1,0,0]

Python + NumPy, 45 bytes

-5 thanks @att

lambda a,p:a.reshape(p*0+2).transpose(p).flat

Attempt This Online!

Expects the binary string and the permutation as NumPy arrays and returns a NumPy flatiter object.

How?

Quite literal approach: Arranges the input sequence into a 2x2x...x2 hypercube, shuffles dimensions according to permutation, and flattens the result.

Uiua, 10 bytes

⊏⍜⊙⋯≡⊏¤⊙°⊏

Try it!

Takes input with the permutation as a 0-indexed array of indices, followed by the binary string.

⊏⍜⊙⋯≡⊏¤⊙°⊏
         ⊙°⊏ # create an array of indices
 ⍜⊙⋯        # convert to binary
      ≡⊏¤     # permute the bits
 ⍜⊙⋯        # convert back to numbers
⊏             # index into s

Python, 113 110 bytes

lambda s,p,n:[s[i]for i in g(range(n),*p[::-1])]
g=lambda s,h,*t:sorted(t and g(s,*t)or s,key=lambda i:i>>h&1)

-3 thanks to Karl

Attempt This Online!

Probably golfable and loses to a more direct approach, but this one is just too much fun. (2*&ÞƒJ’$}‘ị for 11 in Jelly--thanks 1-indexing...) Takes an inverse 0-indexed permutation list \$[\sigma^{-1}(0 ),...,\sigma^{-1}(n-1)]\$, where the inverse is equivalently the grade-up, alongside \$2^n\$.

Since sorted is stable, this sorts by each bit in permutation order, essentially "bubbling" that bit to most significant (w.r.t. the destination indices) before being "pushed down" by the next.

A little more digestible:

lambda s,p,n:[s[i]for i in reduce(lambda x,h:sorted(x,key=lambda i:i>>h&1),p,range(n))]
from functools import*

Python3, 113 bytes

lambda n,s,o:''.join(s[int(''.join(x for _,x in sorted([*zip(o,bin(j)[2:].zfill(n))])),2)]for j in range(len(s)))

Try it online!

Charcoal, 16 bytes

⭆θ§θΣEη∧&κX²μX²λ

Try it online! Link is to verbose version of code. Takes s as the first input as a list or bitstring and σ as the second input as a list (or string if n<11) of 0-indexed destination indices and outputs a bitstring. Explanation:

 θ                  First input `s`
⭆                   Map over characters and join
   θ                First input `s`
  §                 Indexed by
      η             Second input `σ`
     E              Map over indices
         κ          Outer index
        &           Bitwise and
           ²        Literal integer `2`
          X         Raised to power
            μ       Source index
       ∧            Logical And
              ²     Literal integer `2`
             X      Raised to power
               λ    Destination index
    Σ               Take the sum
                    Implicitly print

(If you run this code on ATO instead of TIO then you can also pass σ as a dictionary mapping 0-indexed source indices to destination indices.)