setIndex with bufferGeometry is different to a presort method

I have a buffer geometry in which I have to rearrange the “position”, “normal”, “color” attributes, but want to leave the “weights” attribute unchanged. My first method works exactly as it should

reorder-function for “position”, “normal”, “color” attribute

   function Unindex(src) {
      const dst = [];
      for (let i = 0, n = indices.length; i < n; i+= 3) {
        const i1 = indices[i] * 3;
        const i2 = indices[i+1] * 3;
        const i3 = indices[i+2] * 3;

        for (let j = 0; j < 3; j++) {
          dst.push(src[i1 + j]);
        }
        for (let j = 0; j < 3; j++) {
          dst.push(src[i2 + j]);
        }
        for (let j = 0; j < 3; j++) {
          dst.push(src[i3 + j]);
        }
      }
      return dst;
    }

    //reorder the attributes
    const uiPositions = Unindex(positions, 3);
    const uiNormals = Unindex(normals, 3);
    const uiColours = Unindex(colours, 3);
    //keep weights uneffected
    const uiWeights = weights;

    const bytesInFloat32 = 4;
    const positionsArray = new Float32Array(new ArrayBuffer(bytesInFloat32 * uiPositions.length));
    const normalsArray = new Float32Array(new ArrayBuffer(bytesInFloat32 * uiNormals.length));
    const coloursArray = new Float32Array(new ArrayBuffer(bytesInFloat32 * uiColours.length));
    const weightsArray = new Float32Array(new ArrayBuffer(bytesInFloat32 * uiWeights.length));
   
   //set the attributes
    positionsArray.set(uiPositions, 0);
    normalsArray.set(uiNormals, 0);
    coloursArray.set(uiColours, 0);
    weightsArray.set(uiWeights, 0);
  
   geometry.setAttribute('position', new THREE.Float32BufferAttribute(positionsArray, 3));
   geometry.setAttribute('normal', new THREE.Float32BufferAttribute(normalsArray, 3));
   geometry.setAttribute('color', new THREE.Float32BufferAttribute(coloursArray, 3));
   geometry.setAttribute('weights', new THREE.Float32BufferAttribute(weightsArray, 4));
  

And now the new more elegant way with an IndexArray for reorder:
The index order in the indexArray is the same as follows from the rearrangement with the Unindex(src) function (same indices). So far so good because that’s exactly what I want, the geometry looks the same as with the first method with Unindex(src).

However, the weights attributes should remain unchanged, because they are already correctly ordered. But something is wrong because the result with the weights which affect the material on the geometry looks different from my first way (wrong).
I call setAttribute for “weights” only after resorting for “position”, “normal”, “color”. Therefore I would expect the same result as on the first way. What am I doing wrong?

  const bytesInFloat32 = 4;
  const positionsArray = new Float32Array(new ArrayBuffer(bytesInFloat32 * positions.length));
  const normalsArray = new Float32Array(new ArrayBuffer(bytesInFloat32 * normals.length));
  const coloursArray = new Float32Array(new ArrayBuffer(bytesInFloat32 * colours.length));
  const indicesArray = new Uint32Array(new ArrayBuffer(bytesInFloat32 * indices.length));
  const weightsArray = new Float32Array(new ArrayBuffer(bytesInFloat32 * weights.length));

  positionsArray.set(positions, 0);
  normalsArray.set(normals, 0);
  coloursArray.set(colours, 0);
  indicesArray.set(indices, 0);
  weightsArray.set(weights, 0);

  geometry.setAttribute('position', new THREE.Float32BufferAttribute(positionsArray, 3));
  geometry.setAttribute('normal', new THREE.Float32BufferAttribute(normalsArray, 3));
  geometry.setAttribute('color', new THREE.Float32BufferAttribute(coloursArray, 3));
  geometry.setIndex(new THREE.BufferAttribute(indicesArray, 1));
  
  geometry.attributes.position.needsUpdate = true;
  geometry.attributes.normal.needsUpdate = true;
  geometry.attributes.color.needsUpdate = true;
    
  geometry.setAttribute('weights', new THREE.Float32BufferAttribute(weightsArray, 4));