Accessing Set Entities
 
 Set entities are treated within VDL as one-dimensional arrays, each element being an object with a value and a label property.  
 
  You can access the elements of a set with the square bracket 
 [ ] notation. Set entities are simple arrays and it is very common to iterate over them. The following markup: 
 
 
<vdl-section>
  <vdl-column vdl-repeat="=item in scenario.entities.RISK">
    <p vdl-text="=item.value"></p>
  </vdl-column>
</vdl-section> 
 renders as: 
  
  
   
  
 
  Loops and the 
 <vdl-repeat> element are covered thoroughly in 
 Using Loops with Arrays and Sets. 
 
 
  Rendered View of a Set Entity
 If you wish to extract individual elements from a set entity, you need to protect the statement with a guard, such as: 
 
 
<p vdl-text="=scenario.entities.RISK.length && 
              scenario.entities.RISK[0].value ? 
              scenario.entities.RISK[0].value :
              '' "></p>              
 By default, there is no guarantee about the order in which members of a set entity will be returned. However, within a 
 <script> block, a 
 set sorter function can be assigned via the JavaScript API. 
 
                <script>
function setSorter(originalSet) { 
    // Sort the set, for example, in reverse 
    // integer order for a set of integers
    return originalSet.sort(function(a,b) {
                              return a < b;
                           });
    }
insight.addSetSorter('MySet',setSorter);
</script> 
 
