1

If I have ul li with a number inside the li, how can I order all the ul by this number (the Higher should be first)?

For example I have that html that I can't change

<ul id="ul-list">
    <li>
        <div class="name">product 1</div>
        <div class="rating">85</div>
    </li>
    <li>
        <div class="name">product 2</div>
        <div class="rating">20</div>
   </li>
    <li>

        <div class="name">product 3</div>
        <div class="rating">95</div>
    </li>
</ul>

I want re-order that list so product 3 will be the first one because that item has the highest rating, and product 2 will be the last one because that product has the lowest rating

Daniel Ezra
  • 1,424
  • 3
  • 14
  • 21
  • May be interested in [this related question](https://stackoverflow.com/questions/21600802/jquery-sort-list-based-on-data-attribute-value) – CRice Mar 24 '18 at 01:35
  • Btw your html is not correct. There are some `
  • ` without content. Also it's better to sort when constructing the html, either with php or any other backend or data support.
  • – Isac Mar 24 '18 at 01:45
  • thanks, it's correct now – Daniel Ezra Mar 24 '18 at 01:52