.. ******************************************************************************* * MetaFactory.io R2 * Technical Documentation * * File name : FM_ComparatorFactory.rst * Created by : Marnix Bochove (original text) * Last update : 06-04-2021 * Updated by : Niels de Nies * * MetaFactory BV Amsterdam ******************************************************************************* .. include:: /inline-images.txt .. include:: /external-links.txt Freemarker context object: comparatorFactory ============================================ .. rubric:: Purpose Returns sort elements by the value of the specified property. .. list-table:: **All Methods** :widths: 10 30 :header-rows: 1 :class: tight-table * - Modifier and Type - Method and Description * - Comparator - createElementComparator(String property) Creates an ElementComparator which compares using property .. code-block:: @param property name of element to use for comparison @return ElementComparator .. rubric:: Example of usage .. code-block:: <#assign labelAttributes = metafactory.findChildrenByProperty(currentModelObject, "attribute", "label")> <#assign labelReferences = metafactory.findChildrenByProperty(currentModelObject, "reference", "label")> <#assign all = labelAttributes + labelReferences> <#--comparator sorts elements by value of the specified property--> <#assign comparator = comparatorFactory.createElementComparator("label" )> <#assign sortedItems = metafactory.sort(all, comparator)> <#if sortedItems.size() == 0 > <#-- No properties found --> <#else> <#-- Normal behaviour -->