Question: * * Question: * * A computer science department is developing a program to assign students to study groups based on their grades and interests.

**Question:**
A computer science department is developing a program to assign students to study groups based on their grades and interests. You are tasked with creating a function in Python that will:
1. Accept a list of students, where each student is represented by a dictionary containing their `name`,`grade`, and `interest` fields. For example:
```python
students =[
{"name": "Alice", "grade": 85, "interest": "AI"},
{"name": "Bob", "grade": 90, "interest": "Data Science"},
{"name": "Charlie", "grade": 78, "interest": "AI"},
{"name": "Diana", "grade": 92, "interest": "Cybersecurity"},
{"name": "Eve", "grade": 85, "interest": "Data Science"},
]
```
2. Sort students by their `grade` in descending order. In case of a tie in grades, further sort by their `interest` alphabetically.
3. Group students with the same grade and interest together, and return the groups as a list of lists. Each inner list should represent a unique group of students with the same grade and interest.
**Function Signature:**
```python
def group_students(students: list)-> list:
# Your code here
```
**Sample Input:**
```python
students =[
{"name": "Alice", "grade": 85, "interest": "AI"},
{"name": "Bob", "grade": 90, "interest": "Data Science"},
{"name": "Charlie", "grade": 78, "interest": "AI"},
{"name": "Diana", "grade": 92, "interest": "Cybersecurity"},
{"name": "Eve", "grade": 85, "interest": "Data Science"},
]
```
**Sample Output:**
```python
[
[{"name": "Diana", "grade": 92, "interest": "Cybersecurity"}],
[{"name": "Bob", "grade": 90, "interest": "Data Science"}],
[
{"name": "Alice", "grade": 85, "interest": "AI"},
{"name": "Eve", "grade": 85, "interest": "Data Science"},
],
[{"name": "Charlie", "grade": 78, "interest": "AI"}]
]
```
**Explanation:**
The function organizes students first by grades (in descending order) and then groups them by their interests where applicable.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!