Editing Ar CustomSort
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 5: | Line 5: | ||
Ar_CustomSort will repeatedly take 2 elements from the array to sort, and pass them to the UDF as parameters in the form of two single element arrays. Your UDF determines how the values of the 2 array var parameters should be sorted in relation to each other. | Ar_CustomSort will repeatedly take 2 elements from the array to sort, and pass them to the UDF as parameters in the form of two single element arrays. Your UDF determines how the values of the 2 array var parameters should be sorted in relation to each other. | ||
This is useful if you wish to sort forms according to anything other than their name/formID (eg weight, size, skills etc), or sub-arrays. You let the function know that one element should be considered 'earlier than' or 'less than' in the resulting array's order by letting the UDF return 'true', ie: [[SetFunctionValue]]. | This is useful if you wish to sort forms according to anything other than their name/formID (eg weight, size, skills etc), or sub-arrays. You let the function know that one element should be considered 'earlier than' or 'less than' in the resulting array's order by letting the UDF return 'true', ie: [[SetFunctionValue]]. | ||
|name = Ar_CustomSort | |name = Ar_CustomSort | ||
Line 16: | Line 14: | ||
|Name = ComparisonUDF | |Name = ComparisonUDF | ||
|Type = script}}{{FunctionArgument | |Type = script}}{{FunctionArgument | ||
|Name = <i> | |Name = <i>SortDescending</i> | ||
|Type = <i>bool</i>}}}} | |Type = <i>bool</i>}}}} | ||
==Example== | ==Example== | ||
Line 64: | Line 62: | ||
</pre> | </pre> | ||
If the Ar_CustomSort function was called with the optional | If the Ar_CustomSort function was called with the optional descendingbool, it'll sort the array in reverse order, which in our case means in <i>ascending</i> order (since its based on UDF) of medicine skill: | ||
<pre> | <pre> | ||
0 GSJoeCobbRef | 0 GSJoeCobbRef |