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]].  
You can define the sorting method any way you like, but it must be definitive, otherwise an infinite loop (CTD) may result.


  |name = Ar_CustomSort
  |name = Ar_CustomSort
Line 16: Line 14:
   |Name = ComparisonUDF
   |Name = ComparisonUDF
   |Type = script}}{{FunctionArgument
   |Type = script}}{{FunctionArgument
   |Name = <i>ReverseSort</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 ReverseSort boolean, it'll sort the array in reverse order, which in our case means in <i>ascending</i> order of medicine skill (due to implementation of the UDF):
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

Please note that all contributions to the Fallout3 GECK Wiki are considered to be released under the Creative Commons Attribution-ShareAlike (see GECK:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

Cancel Editing help (opens in new window)