I have a main list with two columns. Within these columns, each div has multiple classes, when you select one of those classes, I want to order the columns so they are even. Here's an example of what I'm starting with:
<div class="left">
<div class="dot blue">blue one</div>
<div class="dot red">red one</div>
<div class="dot orange">orange one</div>
<div class="dot red">red two</div>
<div class="dot red">red three</div>
</div>
<div class="right">
<div class="dot red">red four</div>
<div class="dot blue">blue two</div>
<div class="dot blue">blue three</div>
<div class="dot blue">blue four</div>
<div class="dot orange">orange two</div>
</div>
After clicking a toggling button that I have for "red", I want to hide everything except the red dots, but sort the red ones evenly between the two columns. I can hide everything correctly, but not sure how to make the four red divs even between the "left" and "right" divs. Here's the output I would like to have:
<div class="left">
<div class="dot red">red one</div>
<div class="dot red">red two</div>
</div>
<div class="right">
<div class="dot red">red three</div>
<div class="dot red">red four</div>
</div>
Thanks in advance.