C
C#2y ago
Oli

How do I sort lists from a text file

Just curious how to take lines from a text file into a list then sort the list in terms of highest score, each line would be their own object and id like to output the highest amount of saves/score
5 Replies
Oli
Oli2y ago
thanks in advance
Oli
Oli2y ago
i tried doing something by looking up the syntax however in the first foreach i get a cant convert char to string error
Oli
Oli2y ago
despite declaring path as a string
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Pobiega
Pobiega2y ago
Kazaam nailed it, you're not actually reading from a file. Check out the File.ReadAllLines method for more details on how to do that easily. Then, I'd suggest using lines.Select(x => ...) to turn each line of text (a string) into an object with what I guess is a score and a name. After that you can order the list before finalizing it with .ToList()