Code: Select all
table.append({integervalue, stringvalue});
table.sort();
Code: Select all
table.append({integervalue, stringvalue});
table.sort();
Code: Select all
// function SortMultiArrayByIndex(MultiArray, SubIndex)
// (Function added 26-Apr-2000 by Myrathi)
// This function will sort an array of arrays (or structures) by
// the contents of the sub-index provided. So, if you have an
// array (zCoords) of [x,y,z] structures, calling the function
// with 'fn(zCoords,2)' will sort by the second sub-index... that
// is, the 'y' member. Returns '0' if the SubIndex is invalid
// (only checks against the first index)
function SortMultiArrayByIndex(MultiArray, SubIndex)
var ArrayLen:= Len (MultiArray);
if (ArrayLen < 2)
return MultiArray;
endif
if (SubIndex > len (MultiArray[1]))
return 0;
endif
var i, k, f, s;
for (i:= 1; i < ArrayLen; i:= i + 1)
for (k:= i + 1; k <= ArrayLen; k:= k + 1)
f:= MultiArray[i];
s:= MultiArray[k];
if (s[SubIndex] < f[SubIndex])
MultiArray[i]:= s;
MultiArray[k]:= f;
endif
endfor
Sleepms(2);
endfor
return MultiArray;
endfunction