Mister Miyagi rät:
1. Auftragen
PHP-Code:
/*
Array = [2,6,3,7,8,4,1,5];
_g = [Array,"-_f"] call sortArray.sqf
Array wird zu [8,7,6,5,4,3,2,1]
*/
private ["_a","_b","_c","_j","_k","_d","_e","_f","_g"];
_a = _this select 0;
_b = _this select 1;
if (count _a == count _a && _b == _b) then {
_g = true;
_count = count _a;
_c = [];
_c resize _count;
_j = 0;
while "_j < _count" do
{
_f = _a select _j;
_c set [_j,call _b];
_j = _j + 1;
};
_j = 0;
while "_j < _count -1" do
{
_k = _j + 1;
while "_k < _count" do
{
if (_c select _j > _c select _k) then
{
_e = _c select _j;
_c set [_j,(_c select _k)];
_c set [_k,_e];
_d = _a select _j;
_a set [_j,(_a select _k)];
_a set [_k,_d];
};
_k = _k + 1;
};
_j = _j + 1;
};
} else
{
_g = false;
};
_g;
2. Polieren
Die Werte aus dem neuen Array kannste mit _this select 0, _this select 1, _this select 2 fischen.
Die Funktion sortArray.sqf ist (glaube ich) von Spinor
__________________
"Um nirgends eine gähnende Leere zu lassen, wollen wir uns vorstellen, daß aller Orten und zu jeder Zeit etwas Wahrnehmbares vorhanden ist. Um nicht Materie oder Elektrizität zu sagen, will ich für dieses Etwas das Wort Substanz brauchen."
Hermann Minkowski