sortBodiesIntoGroups is now working all right. Do note that you may want to adjust the sorting of the bodies accordingly to the problem (linearly, logarithmically, etc.)
Merged.