Update merge_groups.cpp

Heavily modified wesley_merge
Everything should be working now
It works without taking a list, but can be easily ported to take a list