I want to sort an array in a way that it gives back three arrays. So
var myArray = [\'1\',\'2\',\'3\',\'1\',\'2\',\'3\',\'1\',\'2\',\'3\',\'1\',\'2\',\'3\',\'1\'
If you're looking for high-order solution (using methods, like Array.prototype.reduce()) following approach might work:
const arr = ['1','2','3','1','2','3','1','2','3','1','2','3','1','2','3','1','2','3','1','2','3','1','2','3','1','2','3','1','2','3','1','2','3','1','2','3','1','2','3','1','2','3','1','2','3','1','2','3','1','2','3','1','2','3'];
const [arr1,arr2,arr3] = arr.reduce((res,e,i) => (res[i%3].push(e),res), [[],[],[]]);
console.log(`arr1 = ${JSON.stringify(arr1)}`);
console.log(`arr2 = ${JSON.stringify(arr2)}`);
console.log(`arr3 = ${JSON.stringify(arr3)}`);
.as-console-wrapper{min-height:100%}
p.s. got a sneak peek at this (universal) solution to make mine a bit more compact