Sort a list based on class as well as values
I need to do a sort of nested sorting.
- <ul class="nested">
- <li class="a-group">4</li>
- <li class="a-group">2</li>
- <li class="a-group">1</li>
- <li class="a-group">3</li>
-
- <li class="b-group">4</li>
- <li class="b-group">2</li>
- <li class="b-group">1</li>
- <li class="b-group">3</li>
-
- <li class="c-group">4</li>
- <li class="c-group">2</li>
- <li class="c-group">1</li>
- <li class="c-group">3</li>
- </ul>
So is there a way I could sort each value within each group, so that I end up with this result:
//Group A
1
2
3
4
So far I only know the simple way of doing this, by sorting without taking each class (group) into account.