Usage

Syntax: array.sortbyvalue("str variablename", "str type", boolean ascending)

Explanation

Will sort a array depending on the variable value.

variablename; Variable of the array members which is compared.
type; Variable type can be "string", otherwise it is sorted by float value.
boolean: Sort by ascending (I.e: 1 to 9)

Example

function onCreated() {
  temp.array = {
	{"item3", 3, true},
	{"item5", 5, false},
	{"item6", 6, true},
	{"item1", 1, false},
	{"item2", 2, false},
	{"item4", 4, false}
  };
  for(temp.i = 0; temp.i < temp.array.size(); temp.i++) { 
	temp.array[temp.i]. sortvalue = temp.array[temp.i][0]; 
  }
  temp.array.sortbyvalue("sortvalue", "string", true); 
  echo(temp.array);
}

... Will output
{
  {"item1", 1, false},
  {"item2", 2, false},
  {"item3", 3, true},
  {"item4", 4, false},
  {"item5", 5, false},
  {"item6", 6, true}
}
in RC when on the serverside, or in your F2 menu when on the clientside.

Categories

CategoryObjectFunction
CategoryFunctionClientside
CategoryFunctionServerside
CategoryExpansionRequired

There are no comments on this page. [Add comment]

Valid XHTML 1.0 Transitional :: Valid CSS :: Powered by WikkaWiki