src/dual-listbox.js
/**
     * Sorts the <option>'s in the underlying <select> in order to ensure
     * that submitted form value are in the correct order.
     *
     * Note: This method must be called before {@link _sortSelected} as it
     *       relies on the selected elements being in the old state.
     *
     * @private
     * @param {int} oldIndex
     * @param {int} newIndex
     * @return {void}
     */
Sorts the 's in the underlying  in order to ensure
that submitted form value are in the correct order.

This method must be called before  _sortSelected as it
relies on the selected elements being in the old state.

@private
@param {int} oldIndex
@param {int} newIndex
@return {void}
Sorts the ' s in the underlying in order to ensure that submitted form value are in the correct order . This method must be called before _sortSelected as it relies on the selected elements being in the old state . @private @param { int } oldIndex @param { int } newIndex @return { void }
_sortUnderlyingSelectOptions(oldIndex, newIndex) {
        const oldValue = this.selected[oldIndex].getAttribute("data-id");
        const newValue = this.selected[newIndex].getAttribute("data-id");
        const oldOptionIndex = [...this.select.children].findIndex(
            (option) => option.value === oldValue
        );
        const newOptionIndex = [...this.select.children].findIndex(
            (option) => option.value === newValue
        );
        const option = this.select.children[oldOptionIndex];
        option.remove();
        this.select.insertBefore(option, this.select.children[newOptionIndex]);
    }
_sortUnderlyingSelectOptions ( oldIndex , newIndex ) { const oldValue = this . selected [ oldIndex ] . getAttribute ( "data-id" ) ; const newValue = this . selected [ newIndex ] . getAttribute ( "data-id" ) ; const oldOptionIndex = [ ... this . select . children ] . findIndex ( ( option ) => option . value === oldValue ) ; const newOptionIndex = [ ... this . select . children ] . findIndex ( ( option ) => option . value === newValue ) ; const option = this . select . children [ oldOptionIndex ] ; option . remove ( ) ; this . select . insertBefore ( option , this . select . children [ newOptionIndex ] ) ; }
Sorts the <option>'s in the underlying <select> in order to ensure
 that submitted form value are in the correct order.
Sorts the <option > ' s in the underlying <select > in order to ensure that submitted form value are in the correct order .
// `this.selected` are the list elements that are currently 'selected' in // the right box. The indexes of these are different from the indexes of the // underlying select, since the latter contains all options. The indexes are // mapped correctly using `data-id` which contains the value of the option. // Remove old element // Re-insert it at correct posision