Sorting binary outcomes using std::deque. by Taylor Stapleton

Well at least I thought it was clever. Ok, so imagine you have a collection of things, and each of these things has a binary property. You need to take this list and order it such that all the items with their property set to 'true' should be first in the list. I'm sure there are a number of clever tricks to doing this, however, my new favorite is using std::deque. The only reason std::deque works well is because not only can it add elements to the end of its container in constant time, but it can also add elements to the front of its container in constant time (using push_back and push_front respectively). As an example, on the left below, I have a rudimentary inefficient method of doing this binary outcome sorting using std::list, and on the right, I showcase the std::deque method.