title: Rearrange existing options based boolean value
body: <p>i would like to know is there a way to rearrange existing options based on boolean value ?</p>
  <p>Example;</p>
  <blockquote>
  <p>If matchtime===true, option['time'] must have priority in the options list
  If matchquality===true, option['quality'] must also be priority in the options list</p>
  </blockquote>
  <pre><code>&lt;form&gt; 
      &lt;select name=&quot;option_id&quot; &gt;
          &lt;option disabled selected value&gt; -- select a category -- &lt;/option&gt;
          &lt;optgroup label=&quot;Recommended&quot;&gt;
          &lt;option disabled &gt; ---- &lt;/option&gt;
          &lt;/optgroup&gt; --&gt;
          &lt;optgroup label=&quot;All Category&quot;&gt;
          &lt;option id=&quot;time&quot; value=&quot;time&quot; &gt;Time &lt;/option&gt;
          &lt;option id=&quot;quality&quot; value=&quot;Quality&quot; &gt;Quality&lt;/option&gt;
          &lt;option id=&quot;management&quot; value=&quot;management&quot; &gt;management&lt;/option&gt;
          &lt;/optgroup&gt;
      &lt;/select&gt;&lt;/form&gt;
  </code></pre>
  <p>Javascript:</p>
  <pre><code>var sel=this.form.elements['option_id'];
  var groups = sel.getElementById('optgroup');
  groups=groups[0];
  var opt=document.createElement('option');
  opt.appendChild(document.createTextNode(&quot;newoptions&quot;));
  var matchtime=true;
  var matchquality = false;
  if(matchtime===true){
     groups.appendChild(opt);
  }
  </code></pre>
  <p>Extra:</p>
  <p>I want to create an autosuggest category based on boolean value. If possible, i also want to label the options with the word &quot;Recommended&quot;.</p>
  <p>If not possible, i was thinking on arrange them using optgroup to separate options that its boolean value is true.</p>
  <p>Reference link: <a href="https://www.dyn-web.com/tutorials/forms/select/option/dom-demo.php" rel="nofollow noreferrer">https://www.dyn-web.com/tutorials/forms/select/option/dom-demo.php</a></p>