It’s something that’s probably best left to JS but flexbox can sort them that using the order
property.
https://codepen.io/Paulie-D/pen/QaKYKK
There is no possibility of adding a border since there is no element to apply it to. You could possibly do something with pseudo-elements but that sounds really messy especially as you there is no nth-of-class
.
Frankly it makes more sense to ensure that your elements are encapsulated before they are added to the DOM….not after.
But as I said, you’re better of doing this with JS.