Sorting Multiple Nested Tuple Data

i had data as Below:
{
"data": [
{
"_index": "school",
"_type": "NestedSort",
"_id": "1",
"_score": 1,
"_source": {
"studentId": "1",
"student": [
{
"program": "Computer",
"type": "Student",
"value": 100
},
{
"program": "Architecture",
"type": "Student",
"value": 200
},
{
"program": "Civil",
"type": "Teacher",
"value": 150
}
]
}
},
{
"_index": "school",
"_type": "NestedSort",
"_id": "2",
"_score": 1,
"_source": {
"studentId": "2",
"student": [
{
"program": "Elex",
"type": "Student",
"value": 400
},
{
"program": "Computer",
"type": "Teacher",
"value": 250
},
{
"program": "Electronics",
"type": "Student",
"value": 150
}
]
}
},
{
"_index": "school",
"_type": "NestedSort",
"_id": "3",
"_score": 1,
"_source": {
"studentId": "3",
"student": [
{
"program": "Computer",
"type": "Teacher",
"value": 500
}
]
}
}
]
}

Now, when i try to sort by program field i.e Nested field (student.program), it doesnot give accurate result. Please Suggest for that case.

Can you post the result you'd expect for clarification?

DataSource:
{
"took": 30,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 3,
"max_score": 1,
"hits": [
{
"_index": "school",
"_type": "NestedSort",
"_id": "1",
"_score": 1,
"_source": {
"studentId": "1",
"student": [
{
"program": "Computer",
"type": "Student",
"value": 100
},
{
"program": "Architecture",
"type": "Student",
"value": 200
},
{
"program": "Civil",
"type": "Teacher",
"value": 150
}
]
}
},
{
"_index": "school",
"_type": "NestedSort",
"_id": "2",
"_score": 1,
"_source": {
"studentId": "2",
"student": [
{
"program": "Elex",
"type": "Student",
"value": 400
},
{
"program": "Computer",
"type": "Teacher",
"value": 250
},
{
"program": "Electronics",
"type": "Student",
"value": 150
}
]
}
},
{
"_index": "school",
"_type": "NestedSort",
"_id": "3",
"_score": 1,
"_source": {
"studentId": "3",
"student": [
{
"program": "Computer",
"type": "Teacher",
"value": 500
}
]
}
}
]
}
}

Query I had Implement:
{
"size": 3,
"sort": [
{
"student.program": {
"order": "desc"
}
}
],
"query": {
"filtered": {
"query": {
"match_all": {}
}
}
}
}

Expected Result;
{
"took": 13,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 3,
"max_score": null,
"hits": [
{
"_index": "school",
"_type": "NestedSort",
"_id": "1",
"_score": 1,
"_source": {
"studentId": "1",
"student": [
{
"program": "Architecture",
"type": "Student",
"value": 200
},
{
"program": "Civil",
"type": "Teacher",
"value": 150
},
{
"program": "Computer",
"type": "Student",
"value": 100
}
]
}
},
{
"_index": "school",
"_type": "NestedSort",
"_id": "2",
"_score": 1,
"_source": {
"studentId": "2",
"student": [
{
"program": "Computer",
"type": "Teacher",
"value": 250
},
{
"program": "Electronics",
"type": "Student",
"value": 150
},
{
"program": "Elex",
"type": "Student",
"value": 400
}
]
}
},
{
"_index": "school",
"_type": "NestedSort",
"_id": "3",
"_score": 1,
"_source": {
"studentId": "3",
"student": [
{
"program": "Computer",
"type": "Teacher",
"value": 500
}
]
}
}
]
}
}