Implemented groupBy as discussed in issue #214, along with documentation and tests