Whatever message this page gives is out now! Go check it out!
StructNew(type, sortType, sortOrder, localeSensitive)StructNew(type,callback)Parameter | Description |
type | (Optional) The type of struct to be created. This is new in Adobe ColdFusion (2016 release). You can specify either "Ordered" or leave structType blank. |
sortType | (Optional) Sort types are text or numeric. |
sortOrder | (Optional) Ascending ("asc") or descending ("desc"). |
localeSensitive | (Optional) True or false. |
callback | (Optional) A comparator function that compares the keys and returns 1, 0, or -1. |
<cfscript>
myStruct=StructNew("Ordered");
myStruct.item1="Old Trafford";
myStruct.item2="Anfield";
myStruct.item3="Stamford Bridge";
myStruct.item4="Villa Park";
myStruct.item5="St James Park";
myStruct.item6="Emirates Stadium";
myStruct.item7="Etihad Stadium";
WriteDump(myStruct);
</cfscript><cfscript>
// Create a struct of type ordered with sort type as text and sort order as ascending.
someStruct=StructNew("ordered","text","asc",false);
someStruct.jonas = {age=26, department="IT"};
someStruct.jason= {age=29, department="Analytics"};
someStruct.johnnie = {age=31, department="Accounting"};
someStruct.john = {age=31, department="Audit"};
WriteDump(someStruct);
</cfscript><cfscript>
sorted = structNew("ordered", function(e1value,e2value,e1key,e2key)
{
return compare(e1key,e2key);
});
sorted.azure = "blue";
sorted.adze = "tool";
sorted.baffle = 01;
sorted.adamantium = "dork";
sorted.alabama = 3;
sorted.ballad = 007;
sorted.age = 36;
sorted.aabc= "allardyce";
sorted.baleful="hodgson";
sorted.aardvark=-7;
sorted.back="sort";
writedump(sorted);
</cfscript><cfscript>
animals=StructNew("casesensitive")
animals.Aardwolf="Proteles cristata"
animals.Aardvark="Orycteropus afer"
animals.Alligator="Mississippiensis"
animals.Albatross="Diomedeidae"
writeDump(animals)
</cfscript><cfscript>
animals=StructNew("casesensitive")
animals.Aardwolf="Proteles cristata"
animals.aardvark="Orycteropus afer"
animals.Alligator="Mississippiensis"
animals.albatross="Diomedeidae"
writeDump(animals)
</cfscript><cfscript>
animals=StructNew("ordered-casesensitive")
animals.Aardwolf="Proteles cristata"
animals.Aardvark="Orycteropus afer"
animals.Alligator="Mississippiensis"
animals.Albatross="Diomedeidae"
writeDump(animals)
</cfscript><cfscript>
animals=StructNew("ordered-casesensitive")
animals.Aardwolf="Proteles cristata"
animals.aardvark="Orycteropus afer"
animals.alligator="Mississippiensis"
animals.Albatross="Diomedeidae"
writeDump(animals)
</cfscript>