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
![](https://utfs.io/f/2832d2c9-d6a7-40b4-b8cc-0579fbd73be2-4pl4mu.png)
5 Replies
thanks in advance
i tried doing something by looking up the syntax however in the first foreach i get a cant convert char to string error
![](https://utfs.io/f/f40bf15d-5da8-4ef2-90a9-d2493e8eac8f-4pl4mu.png)
despite declaring path as a string
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
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()