sort: Difference between revisions
Jump to navigation
Jump to search
Lou Montana (talk | contribs) m (Text replacement - "(\|[pr][0-9]+ *= *[^- ]*) *- *S([a-z ])" to "$1 - s$2") |
Lou Montana (talk | contribs) m (Text replacement - "<sqf>([^↵][^<]*↵[^<]*)<\/sqf>" to "<sqf> $1 </sqf>") |
||
(One intermediate revision by the same user not shown) | |||
Line 6: | Line 6: | ||
|gr1= Arrays | |gr1= Arrays | ||
|descr= Attempts to sort given array either in ascending ([[true]]) or descending ([[false]]) order. {{Feature| | |descr= Attempts to sort given array either in ascending ([[true]]) or descending ([[false]]) order. {{Feature|important|This will '''modify''' the original array!}} | ||
|s1= array [[sort]] order | |s1= array [[sort]] order | ||
Line 23: | Line 23: | ||
|r1= [[Nothing]] | |r1= [[Nothing]] | ||
|x1= <sqf>_arr = [5.21725,1.30859,4,5.03028,1]; | |x1= <sqf> | ||
_arr = [5.21725,1.30859,4,5.03028,1]; | |||
_arr sort true; | _arr sort true; | ||
hint str _arr; //[1,1.30859,4,5.03028,5.21725]</sqf> | hint str _arr; //[1,1.30859,4,5.03028,5.21725] | ||
</sqf> | |||
|x2= <sqf>_dev = ["ja","pa","pa","tram","tara"]; | |x2= <sqf> | ||
_dev = ["ja","pa","pa","tram","tara"]; | |||
_dev sort false; | _dev sort false; | ||
hint str _dev; //["tram","tara","pa","pa","ja"]</sqf> | hint str _dev; //["tram","tara","pa","pa","ja"] | ||
</sqf> | |||
|x3= <sqf> | |x3= <sqf> |
Latest revision as of 19:42, 3 September 2024
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.