-
Notifications
You must be signed in to change notification settings - Fork 148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CBA_fnc_sortNestedArray - Preserve order of elements with same sorting value #1271
Conversation
…th same sorting value
I don't get it. |
Updated the example to be more clear. My use case for this is an array of actions (each with a priority). This addition will allow actions to be sorted in terms of decreasing priority (like current), but also keep actions with the same priority in the order they were added - instead of performing additional unwanted sorting on the full "action sub-arrays". |
Shouldn't that always be the case?
Seems like a bug/oversight to me. I think this does not need additional syntax, but just always sort the way your alt syntax is now. This is the original: https://github.com/CBATeam/CBA_A3/blob/79d52a8338fc9457e6830530794ab6ed03eefd4b/addons/arrays/fnc_sortNestedArray.sqf |
|
||
{ | ||
_helperArray pushBack [_x select _index, _coefficient * _forEachIndex, _x]; | ||
} forEach _array; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please keep the apply
to save N pushBack
commands.
private _helperArray = _array apply {
[_x select _index, _coefficient * _forEachIndex, _x]
};
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no _forEachIndex
in apply
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dang.
When merged this pull request will:
Example (before changing to default behaviour):