I would like to group list

```
{"a", "b", "c", "d", "e", "f", "g"}

```

using second list with group numbers

```
{1,2,1,2,3,3,1}

```

in the following way that it gives me new list

```
{{"a","c","g"},{"b","d"},{"e","f"}}

```

I'd like also that it works in Manipulate, so I could split my list in groups
 dynamically

```
fls = {"p1.DAT", "p2.DAT", "p3.DAT", "p4.DAT", "p5.DAT", "p6.DAT", "p7.DAT", "p8.DAT"};
vars = Table[Symbol["$x" <> ToString@i], {i, fls // Length}];
n = 4;
Manipulate[Evaluate@{vars, fls}, 
 Evaluate[Sequence @@ 
  Table[{{vars[[i]], 1, fls[[i]]}, Range[n]}, {i, 1, 
 vars // Length}]]]

```