-1

I have a list like this

   <ul id="list">
        <li data-ind="1">L</li>
        <li data-ind="2">M</li>
        <li data-ind="3">S</li>
        <li data-ind="4">XL</li>
        <li data-ind="5">XS</li>
    </ul>

I want to sort them like this : XS, S, M, L, XL how can I do this by injecting javascript/jQuery

  • See [Sort an array of objects based on another array of ids](/q/35538509/4642212) and [Sorting a list by data-attribute](/q/32199368/4642212). Familiarize yourself with [how to access and process nested objects, arrays or JSON](/q/11922383/4642212), how to [create objects](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Object_initializer) and use the available [`Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array#Static_methods) methods (both static and on prototype). Have you tried something yourself? – Sebastian Simon Apr 05 '21 at 06:43
  • 2
    [sorting
  • elements alphabetically](https://stackoverflow.com/questions/42722754) . Use [Sort an array in the same order of another array](https://stackoverflow.com/questions/28377495) for sorting
  • – adiga Apr 05 '21 at 06:48