Javascript Group Array Of Objects By Shape