C
C#3y 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
OliOP3y ago
thanks in advance
Oli
OliOP3y 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
OliOP3y ago
despite declaring path as a string
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Pobiega
Pobiega3y 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()
Want results from more Discord servers?
Add your server