Well, I tried it, and it rotates the whole group actually. And when I put the layers out of the groups, it displayed an error message.
Nvm, found why it rotates the group, because I grouped the groups in another one. Now they aren't anymore, it does work fine 🙂
Well, rotation isn't that much of a great idea, because it leaves a lot of holes between the triangles :

This is less elegant; it should shuffle the Layers in the selected Group.


// shuffle layers in active group;
// 2021, use it at your own risk;
if (app.documents.length > 0) {
var myDocument = app.activeDocument;
var aaa = getLayersInGroup ();
if (aaa.length == 2) {shuffleTheLayers (aaa[0].sort(randOrd), aaa[1])}
};
////////////////////////////////////
function getLayersInGroup () {
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
var layerDesc = executeActionGet(ref);
var theIndex = layerDesc.getInteger(stringIDToTypeID("itemIndex"));
var theSection = layerDesc.getEnumerationValue(stringIDToTypeID("layerSection"));
////////////////////////////////////
if (typeIDToStringID(theSection) == "layerSectionStart") {
// anumber is intended to keep track of layerset depth;
var aNumber = 0;
var theCheck = false;
var theArray = new Array;
var thisIndex = theIndex;
while (theCheck == false) {
thisIndex--;
var ref = new ActionReference();
ref.putIndex( charIDToTypeID( "Lyr " ), thisIndex);
var layerDesc = executeActionGet(ref);
var theIndex = layerDesc.getInteger(stringIDToTypeID("itemIndex"));
var theIdentifier = layerDesc.getInteger(stringIDToTypeID("layerID"));
var theName = layerDesc.getString(stringIDToTypeID("name"));
var theSection = typeIDToStringID(layerDesc.getEnumerationValue(stringIDToTypeID("layerSection")));
if (theSection != "layerSectionStart" && theSection != "layerSectionEnd") {theArray.push([theName, theIdentifier])};
if (theSection == "layerSectionStart") {aNumber++};
if (theSection == "layerSectionEnd" && aNumber != 0) {aNumber--};
if (theSection == "layerSectionEnd" && aNumber == 0) {theCheck = true};
}
return [theArray, theIndex]
};
////////////////////////////////////
return [theIndex]
};
////////////////////////////////////
function shuffleTheLayers (theArray, theIndex) {
for (var m = 0; m < theArray.length; m++) {
var idlayer = stringIDToTypeID( "layer" );
var desc3 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putIdentifier( idlayer, theArray[m][1] );
desc3.putReference( stringIDToTypeID( "null" ), ref1 );
var ref2 = new ActionReference();
ref2.putIndex( idlayer, theIndex );
desc3.putReference( stringIDToTypeID( "to" ), ref2 );
executeAction( stringIDToTypeID( "move" ), desc3, DialogModes.NO );
}
};
////// randomize array, thanks to Stephen Chapman, http://javascript.about.com/ //////
function randOrd(){
return (Math.round(Math.random())-0.5)
};