I have a `List` of objects like this:

```
List<Student> student= new ArrayList<Student>();

```

`Student` class looks like:

```
public class Student {
    private String Id;
    private String name;
}

```

I have another `List<String> stuIds = new ArrayList<String>();`

I want to sort `student` list based on `stuIds` list.

Tried this, but not getting the right order:

```
student.forEach(Id -> {

    student.sort(Comparator.comparing(items->stuIds.indexOf(student.getId())));     
});

```

AND

```
Collections.sort(student, 
    Comparator.comparing(item -> stuIds.indexOf(item)));
});

```

Is the sorting not happening because it is `List<Dto>` and `List<String>`? Could someone help here?