alpha993 122 Posted March 31, 2021 I've been scratching my head at a problem with arrays recently but I can't seem to find a decent solution to it. So let's say I have an array that looks like this: [[1,2],[2,1],[3,4],[4,3]]. In this case, the first two elements are combinations of each other, same as the last two. What I am trying to do is to filter this array to remove such combinations and leave only one of them so that the array would look like [[1,2],[3,4]] instead. I'd greatly appreciate any help with this! Share this post Link to post Share on other sites
pierremgi 4906 Posted April 1, 2021 What do you think about: _array = [[1,2],[2,1],["zz","tt"],[4,3],["tt","zz"],[3,2,1]]; _result= []; {_e = +_x; _e sort TRUE; _result pushBackUnique _e} forEach _array; // [[1,2],["tt","zz"],[3,4],[1,2,3]] Spoiler Consolidated for array of anything: _array = [[1,2],[2,1],["zz","tt"],[4,3],["tt","zz"],[3,2,1],6,"hello"]; _result= []; {_e = _x; if (_e isEqualType []) then {_e = +_x; _e sort TRUE}; _result pushBackUnique _e} forEach _array; 1 1 Share this post Link to post Share on other sites
alpha993 122 Posted April 1, 2021 Just tested it and it works wonders. Thanks so much! Share this post Link to post Share on other sites