I'd like to sort some elements which current listed like this:
<div data-type="1"></div>
<div data-type="1"></div>
<div data-type="1"></div>
<div data-type="2"></div>
<div data-type="2"></div>
<div data-type="2"></div>
<div data-type="3"></div>
<div data-type="3"></div>
<div data-type="3"></div>
<div data-type="4"></div>
etc...
I want order then in the pattern of 1,2,3,4,1,2,3,4,1,2,3,4 etc. There may be less on a certain number so at the end it maybe 1,2,4,1,2,1 for example. I'm using JQuery if that simplifies the code at all.
Edit:
I've tried using the JS sort function to no avail because I can't get it to reset to 1 after getting to 4. This is the way 4 different types of generated content are given to me and I can't change anything in the backend.