sort: Difference between revisions
Jump to navigation
Jump to search
Lou Montana (talk | contribs) m (Some wiki formatting) |
Lou Montana (talk | contribs) m (Some wiki formatting) |
||
Line 12: | Line 12: | ||
|p1= array: [[Array]] - Array to be sorted, can also be a nested array.<br><br> | |p1= array: [[Array]] - Array to be sorted, can also be a nested array.<br><br> | ||
All array elements should be one of the following types: | All array elements should be one of the following types: | ||
* [[String]] - Array of strings {{ | * [[String]] - Array of strings {{hl|["a","b","c"...]}} | ||
* [[Number]] - Array of numbers {{ | * [[Number]] - Array of numbers {{hl|[1,2,3...]}} | ||
* [[Array]] - Array of subarrays {{ | * [[Array]] - Array of subarrays {{hl|[<nowiki/>["a",1,2],["b",3,4],["c",5,6]...]}}. Subarrays should be of the same structure. Subarray elements other than [[String]] or [[Number]] will be ignored during sorting. | ||
Mixed arrays {{ | Mixed arrays {{hl|["a",1,[true], ...]}} are not supported and results are undefined.<br><br> | ||
|p2= order: [[Boolean]] - Sorting order. | |p2= order: [[Boolean]] - Sorting order. | ||
Line 54: | Line 54: | ||
}} | }} | ||
{{Note | |||
|user= Killzone_Kid | |||
|timestamp= 20150416181400 | |||
|text= The algorithm for sorting subarrays: compare 1st element, if equal compare 2nd, if equal compare 3rd...etc. | |||
}} | |||
The algorithm for sorting subarrays: compare 1st element, if equal compare 2nd, if equal compare 3rd...etc. | |||
Revision as of 15:36, 27 July 2022
Description
- Description:
- Attempts to sort given array either in ascending (true) or descending (false) order.
- Groups:
- Arrays
Syntax
- Syntax:
- array sort order
- Parameters:
- array: Array - Array to be sorted, can also be a nested array.
All array elements should be one of the following types:- String - Array of strings ["a","b","c"...]
- Number - Array of numbers [1,2,3...]
- Array - Array of subarrays [["a",1,2],["b",3,4],["c",5,6]...]. Subarrays should be of the same structure. Subarray elements other than String or Number will be ignored during sorting.
- order: Boolean - Sorting order.
- Return Value:
- Nothing
Examples
- Example 1:
- Example 2:
- Example 3:
- Example 4:
- Sort buildings by distance and return position of the most distant building:
Additional Information
Notes
-
Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note
- Posted on Apr 16, 2015 - 18:14 (UTC)
- The algorithm for sorting subarrays: compare 1st element, if equal compare 2nd, if equal compare 3rd...etc.