Asked by Abdelmalek Benaimeur
on 19 Apr 2019

I have a list of students , every student has a grade (numeric value)

how can i order the list of those students according to their marks ,

so that the first one in the list is the one who has the highest grade

for example (let's assume that the grades are between 0 and 20)

Alex: 19

Morgan: 12

Erik: 15

Montana:13

Molko:10

Kelsie:16

the list should be lik that

Alex Kelsie Erik Montana Morgan

Answer by Raj
on 19 Apr 2019

Edited by Raj
on 19 Apr 2019

Accepted Answer

Name = {'Alex';'Morgan';'Erik';'Montana';'Molko';'Kelsie'};

Marks = [19;12;15;13;10;16];

% Create a table

InputTable = table(Name, Marks)

% Sort rows of the table

SortedTable = sortrows(InputTable, 2)

Temp_List=SortedTable(:,1)

Required_List=flip(Temp_List)

As I said, It's straighforward. Hope this helps!

madhan ravi
on 19 Apr 2019

Providing complete solution for a homework problem is not recommended.

Raj
on 19 Apr 2019

Sorry! Will take care.

Abdelmalek Benaimeur
on 19 Apr 2019

well sir I don't know if you will believe me or not but when i read your answer

you gave me a hint so i took my laptop and i started trying to find the solution

i know that you know the solution but you wanted me to try first

and you have all my respect,

anyway thank you both

Sign in to comment.

Answer by madhan ravi
on 19 Apr 2019

Hint: Use sort().

Abdelmalek Benaimeur
on 19 Apr 2019

madhan ravi
on 19 Apr 2019

Sign in to comment.

Opportunities for recent engineering grads.

Apply Today
## 2 Comments

## Raj (view profile)

Direct link to this comment:https://de.mathworks.com/matlabcentral/answers/457316-i-appreciate-if-anyone-could-help-me-with-this-problem#comment_695829

## Abdelmalek Benaimeur (view profile)

Direct link to this comment:https://de.mathworks.com/matlabcentral/answers/457316-i-appreciate-if-anyone-could-help-me-with-this-problem#comment_695831

Sign in to comment.