Skip to content

Instantly share code, notes, and snippets.

@tonyjunkes
Last active August 29, 2015 14:13
Show Gist options
  • Save tonyjunkes/9ac2b9fb142685e5d9cb to your computer and use it in GitHub Desktop.
Save tonyjunkes/9ac2b9fb142685e5d9cb to your computer and use it in GitHub Desktop.
<cfscript>
set = {
one : {
alphabet : "a",
maori : "tahi",
roman : "i",
ordinal : "first"
},
two : {
alphabet : "b",
maori : "rua",
roman : "ii",
ordinal : "second"
},
three : {
alphabet : "c",
maori : "toru",
roman : "iii",
ordinal : "third"
},
four : {
alphabet : "d",
maori : "wha",
roman : "iv",
ordinal : "fourth"
}
};
subset = ["four", "two"];
public array function getOrderedSubset(required struct set, required array subset)
output="false"
{
return subset.filter(function(e) {
return structKeyExists(set, e);
}).map(function(v, i) {
set[v].label = v;
return set[v];
});
}
writeDump(getOrderedSubset(set, subset));
</cfscript>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment