Code to sort based on quantities of a data member occuring
int index = 0;
  for (int i = 0; i &lt; 10; ++index, ++i) {
    counts.emplace_back(index, 0);
  }

Not sure why you use index here which is same as i ?

[](auto a, auto b) { return a.second &gt; b.second; }
for (auto i : sort_by) {

a and b, i can be marked const.

 std::vector&lt;int&gt; sort_by(10);
  for (int i = 0; i &lt; 10; ++i) {
    sort_by[i] = counts[i].first;
  }

Not sure that there's a big improvement, but here's a change anyway.
  std::vector&lt;int&gt; sort_by;
  sort_by.reserve(10);
  std::for_each(counts.begin(), counts.end(), [&amp;sort_by](const auto &amp;i) {
    sort_by.push_back(i.first);
  });


for (auto it = devices.begin(); it != devices.end(); ++it) {
  if (it-&gt;fizz == i) {
    std::iter_swap(walker, it);
    ++walker;
  }
}

Can be made a bit simpler by using range based for loop &amp; address instead of iterator. Note the reference in &amp;it.
for (auto &amp;it : devices) {
  if (it.fizz == i) {
    std::iter_swap(walker, &amp;it);
    ++walker;
  }
}