Hi all,
I want to provide for users list of sorting values in Custom Form using vRO Action (for example: tier-1, tier-2), but sort order in Properties object is not alphabetic. Is there some way to sort elements in Properties object?
Examples:
But
Hello!
Properties are not sortable in JavaScript. I use this workaround (only tested in vRA 7.x):
var sortme = ["t1@tier-1","t5@tier-5","t3@tier-3","t2@tier-2","t4@tier-4"]
var val2return = []
for each (item in sortme.sort()) {
var prop = new Properties();
prop.put('label',item.split("@")[0])
prop.put('value',item.split("@")[1])
val2return.push(prop)
}
return val2return
Yep, I did the same as Robert. Create an array of properties, add the properties into the array in a sorted way, and they will be returned in the way you'd expect.