I have an XML similar to this:

```
<Test>
  <grapes>
     <a>TypeA</a>
     <b>value1</b>
  </grapes>
  <oranges>
     <a>TypeB</a>
     <b>value2</b>
  </oranges>
  <apples>
    <a>TypeA</a>
     <b>value3</b>
  </apples>
</Test>

```

where the values are unique but the Type, might be the same.

I am trying to sort it so that the output is similar to this:

```
<group type="TypeA">
  <value v="value1" />
  <value v="value3" />
</group>
<group type="TypeB">
  <value v="value2" />
</group>

```

I am having a hard time making sure the groups are unique in the output and the values are in the right group.

How should my XSL be structured?