def group_features(self, feature_names):
        """
        Topologically sort the given features, then group by path,
        feature type, use_previous, and where.
        """
        features = [self.features_by_name[name] for name in feature_names]
        depths = self._get_feature_depths(features)

        def key_func(f):
            return (
                depths[f.unique_name()],
                f.relationship_path_name(),
                str(f.__class__),
                _get_use_previous(f),
                _get_where(f),
                self.uses_full_dataframe(f),
                _get_groupby(f),
            )

        # Sort the list of features by the complex key function above, then
        # group them by the same key
        sort_feats = sorted(features, key=key_func)
        feature_groups = [
            list(g) for _, g in itertools.groupby(sort_feats, key=key_func)
        ]

        return feature_groups

        Topologically sort the given features, then group by path,
        feature type, use_previous, and where.
        
featuretools/computational_backends/feature_set.py