Adds and implements a sorting algorithm for groups.