I have some buttons on my web page which are looking like this:
<button>Apple</button>
<button>Dog</button>
<button>Text</button>
<button>Boy</button>
<button class='whatNot'>Text</button>
<button class='smth whatNot'>Applepie</button>
<button class='whatNot'>Doge is barking</button>
<button class='smth'>Such a doge</button>
<button class='smth whatNot'>Wow!</button>
<button class='whatNot smth'>Pure delicious</button>
<button>Peach</button>
<button>Trip</button>
Now I want to sort these buttons in alphabetical order without loosing tags and classes. I thought about making that in js: adding all button's names in array and then sort it. But how will I restore their classes afterwards? So, essentially, I just want to sort lines by words inside tags , but to not lose classes of each button during the sorting. Hope, I was clear enough.