NEARBY OPTICAL GALAXIES: SELECTION OF THE SAMPLE AND IDENTIFICATION OF GROUPS