This is a continuation from one of my previous questions:
[If I have a Stream<Class>, how can I access the classes' inherent information such as variables and arrays?](https://stackoverflow.com/questions/72049722/if-i-have-a-streamclass-how-can-i-access-the-classes-inherent-information-su)

I have a class named `CavePerson` with the following structure:

```
public class CavePerson {
   public final int num;
   public final String name;
   public final String gender;
   public final int age;

   public CavePerson (int aNum, String aName, String aGender, int anAge){
      this.num = aNum;
      this.name = aName;
      this.gender = aGender;
      this.age = anAge;
   }

   public static CavePerson lineValues(String line) {
      String array = line.split(",");
      int numA = array[0];
      String nameA = array[1];
      String genderA array[2];
      int ageA = array[3];
      return new CavePerson(numA, nameA, genderA, ageA);
   }
}

```

Each line in this cavepeople.csv file is a CavePerson object:

```
| Num | Name   | Gender  |Age  |
| --- | ----   | ------  | --- |
| 1   | Fred   | Male    | 41  |
| 2   | Wilma  | Female  | 36  |
| 3   | Barney | Male    | 38  |
| 4   | Betty  | Female  | 35  |
| 5   | Dino   | Pet     | 4   |
| 6   | BamBam | Male    | 2   |
| 7   | Puss   | Pet     | 1   |

```

I am trying to practice using streams on datasets. I want to use a BiFunction that takes a stream of type `CavePerson` and a `String`.

This `String` is one of the defined genders in a `CavePerson` object. The stream should return a `String[]`, which contains everyone who falls under a specific gender. My expected outcome should look like:

```
EXPECTED OUTCOME
Given a stream of type `CavePerson` and "Male": [Fred, Barney, BamBam]
Given a stream of type `CavePerson` and "Female": [Wilma, Betty]
Given a stream of type `CavePerson` and "Pet": [Dino, Puss]

```

This is the beginning of the code, but I am not exactly sure where to go from here:

```
static BiFunction<Stream<CavePerson>, String, List<String>> getSortedGenders = (e, q) -> List.of(q);

//e.collect(Collectors.groupingBy(CavePerson -> CavePerson.gender), Collectors.toList());

```