Module: modules/sort-sk


Allows sorting the members of the indicated element by the values of the data attributes. This element does *not* support the elements to sort changing. It assumes the data in the table is constant (otherwise, lit-html will not be able to render it accurately). Add children to that generate click events and that have child content, such as buttons. Add a data-key * attribute to each child element that indicates which data-* attribute the children should be sorted on. Note that all sorting is done numerically, unless the 'data-sort-type=alpha' attribute is set on the element generating the click, in which case the sorting is done alphabetically. Additionally a single child element can have a data-default attribute with a value of 'up' or 'down' to indicate the default sorting that already exists in the data.
Name Description
target The id of the container element whose children are to be sorted.
An example usage, that will present two buttons to sort the contents of

   <sort-sk target=stuffToBeSorted>
     <button data-key=clustersize data-default=down>Cluster Size </button>
     <button data-key=stepsize data-sort-type=alpha>Name</button>

   <div id=stuffToBeSorted>
     <div data-clustersize=10 data-name=foo></div>
     <div data-clustersize=50 data-name=bar></div>