Trying to sort top 3 highscores, need help
I've made a list of highscores, but I'd like to sort out the top 3 ones. I've been looking at some tutorials but im still lost. I'd like some help
10 Replies
allowed to use LINQ ?
yeah
Im allowed to use Linq
Order them by the score and then skip 3
How would I do that?
highscore.OrderBy(score => score.Points_)
and then you just want the first 3 items?
I want top 3 highscores
so if someone had scores 1, 5, 6, 4, 3 it would be 6, 5, 4
okay well you would first use linq as the person above said
Enumerable.OrderBy Method (System.Linq)
Sorts the elements of a sequence in ascending order.
then get it by descending, and get the values out, either through a loop or slicing the list
also a weird thing is that my highscore file doesnt access my text file "highscore.txt" eventhough it should