sort: Difference between revisions
Jump to navigation
Jump to search
Killzone Kid (talk | contribs) mNo edit summary |
Killzone Kid (talk | contribs) (example) |
||
Line 32: | Line 32: | ||
[[hint]] [[str]] _dev; //["tram","tara","pa","pa","ja"]</code> |= Example 2 | [[hint]] [[str]] _dev; //["tram","tara","pa","pa","ja"]</code> |= Example 2 | ||
|x3= <code>_scores = <nowiki>[</nowiki>[123,"bob",15],[123,"bill",20],[200,"dave",21],[200,"steve",11]]; | |x3= <code>#define ASC true | ||
_scores [[sort]] | #define DESC false | ||
_scores = <nowiki>[</nowiki>[123,"bob",15],[123,"bill",20],[200,"dave",21],[200,"steve",11]]; | |||
_scores [[sort]] DESC; | |||
[[hint]] [[str]] _scores; //<nowiki>[</nowiki>[200,"steve",11],[200,"dave",21],[123,"bob",15],[123,"bill",20]]</code> |= Example 2 | [[hint]] [[str]] _scores; //<nowiki>[</nowiki>[200,"steve",11],[200,"dave",21],[123,"bob",15],[123,"bill",20]]</code> |= Example 2 | ||
Revision as of 11:28, 17 April 2015
Description
- Description:
- Attempts to sort given array either in ascending (true) or descending (false) order. All array elements should be one of the following types: Mixed arrays (["a",1,[true]...]) are not supported and results are undefined.
- Groups:
- Uncategorised
Syntax
- Syntax:
- array sort order
- Parameters:
- array: Array
- order: Boolean - true: ascending, false: descending
- Return Value:
- Nothing
Examples
- Example 1:
_arr = [5.21725,1.30859,4,5.03028,1]; _arr sort true; hint str _arr; //[1,1.30859,4,5.03028,5.21725]
- Example 2:
_dev = ["ja","pa","pa","tram","tara"]; _dev sort false; hint str _dev; //["tram","tara","pa","pa","ja"]
- Example 3:
#define ASC true
- define DESC false
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
[[Category:Introduced with arma3dev version 1.43]][[ Category: arma3dev: New Scripting Commands | SORT]][[ Category: arma3dev: Scripting Commands | SORT]]
- Posted on April 16, 2015 - 18:14 (UTC)
- Killzone Kid
- The algorithm for sorting subarrays: compare 1st element, if equal compare 2nd, if equal compare 3rd...etc.