SamueDexterAYG
Member
- Joined
- Jul 7, 2022
- Messages
- 7
- Programming Experience
- 10+
Hello everyone. I am working on a score/grading app. Everything thing works fine except I am struggling with the actual functionality.
I am able to generate the scores as shown below in a listbox but unable to sort them by their value from the greatest to the least and assign the text '1st', '2nd', 'third' etc to the and 'draw' when the values of two or more persons are the same.
What I tried initially was to create a list, the transfer these items of the listbox into the list, sort it in reverse, but still doesnt help.
Seems like I need to split the names from the values and sort them from the highest to the least but if so, I find it difficult to assign the values back to the names accordingly after the sorting has been done and applying the grades 1st', '2nd', 'third', 'draw' etc to them.
I am sorry I couldnt present my effort here. I know LINQ may solve this but I am quite new to C#. I will be grateful for your help and assistance. I am prepared to learn. Thank you.
John: 30
Sarah: 50
David: 7
Joe: 12
Pam: 20
Peter: 53
James: 14
John: 12
DESIRE OUTPUT >>
Peter: 53 - 1st
Sarah: 50 - 2nd
John: 30 - 3rd
Pam: 20 - 4th
James: 14 - 5th
Joe: 12 - Draw
John: 12 - Draw
David: 7
I am able to generate the scores as shown below in a listbox but unable to sort them by their value from the greatest to the least and assign the text '1st', '2nd', 'third' etc to the and 'draw' when the values of two or more persons are the same.
What I tried initially was to create a list, the transfer these items of the listbox into the list, sort it in reverse, but still doesnt help.
Seems like I need to split the names from the values and sort them from the highest to the least but if so, I find it difficult to assign the values back to the names accordingly after the sorting has been done and applying the grades 1st', '2nd', 'third', 'draw' etc to them.
I am sorry I couldnt present my effort here. I know LINQ may solve this but I am quite new to C#. I will be grateful for your help and assistance. I am prepared to learn. Thank you.
John: 30
Sarah: 50
David: 7
Joe: 12
Pam: 20
Peter: 53
James: 14
John: 12
DESIRE OUTPUT >>
Peter: 53 - 1st
Sarah: 50 - 2nd
John: 30 - 3rd
Pam: 20 - 4th
James: 14 - 5th
Joe: 12 - Draw
John: 12 - Draw
David: 7