Search code examples
polymer

How to sort alphabetical dropdown data on polymer


I have a dropdown like this :

<div>
  <paper-dropdown-menu label="Speciality">
    <paper-listbox id="selectSpeciality" slot="dropdown-content" attr-for-selected="name" selected="{{doctor.speciality}}" class="dropdown-content">
      <template is="dom-repeat" items="[[specs]]">
        <paper-item name="[[item]]">[[item]]</paper-item>
      </template>
    </paper-listbox>
  </paper-dropdown-menu>
</div>

And data like this :

sort How to sorting by alpabetical ?

Thanks


Solution

  • You have to order the categories obtained instead of showing them directly, you can create a function that sorts them or better save them already sorted.