Grumpy Old Man 3540 Posted December 16, 2013 Hey folks this one is really tough for me, lets say I have an array like _array1 = [24.37,24.38,24.40,42.44,42.45,87.21,87.22] as you can see it's already sorted in ascending order how can I sort it further so that values that are very close together (like 87.21 and 87.22 as an example) are being put into a new array? Cheers Share this post Link to post Share on other sites
Johnson11B2P 3 Posted December 17, 2013 //sort numbers from lowest to highest _sortedNumbers = [[1,-80,0,480,15,-40],[],{_x},"ASCEND"] call BIS_fnc_sortBy; This can sort your array. How close do you want the values to be to make another Array? Try looking into "BIS_fnc_subSelect". Share this post Link to post Share on other sites
Grumpy Old Man 3540 Posted December 17, 2013 Hey Johnson11B2P, my array was already sorted, I just wanted to filter out values that are close together and put them in a new array, when looking for BIS_fnc_subSelect I stumbled across BIS_fnc_conditionalSelect which looks like it's doing what I need. Cheers Share this post Link to post Share on other sites
daimyo21 2 Posted November 4, 2015 Sorry accidently posted a message that has no relevance here. Share this post Link to post Share on other sites
rübe 127 Posted November 5, 2015 my array was already sorted, I just wanted to filter out values that are close together and put them in a new array, Given your input (_array1) is already sorted (no matter if ascending or descending; doesn't matter), you can do something like this to filter values that are sitting to close to each other: _array1 = [24.37,24.38,24.40,42.44,42.45,87.21,87.22]; _threshold = 0.5; _filtered = []; _last = -1; { if (_forEachIndex == 0) then { _filtered pushBack _x; _last = _x; } else { _diff = abs (_x - _last); if (_diff >= _threshold) then { _filtered pushBack _x; _last = _x; } } } forEach _array1; // use/return _filtered This is absolutely untested B) , but you get the idea. Have some threshold and keep track of the last value you've pushed back, then you can simply compute the difference between the next potential value and the last one pushed back and see if it's larger than the defined threshold. Share this post Link to post Share on other sites
haleks 8206 Posted November 5, 2015 After two years I hope Grumpy had it figured out already! ^^ 1 Share this post Link to post Share on other sites
rübe 127 Posted November 5, 2015 After two years I hope Grumpy had it figured out already! ^^ bwahaha, haven't noticed the necrobump. :rolleyes: Share this post Link to post Share on other sites