C# List<string> OrderBy Split
c#, list
Solution
This would work:
All = All.OrderBy(s => int.Parse(s.Split('|').Last())).ToList();
What would work even better though would be to have a list of a structured type instead of a list of dumb strings. For example, you could have a list of `Tuple<string, int>` and simply sort it by the second member. You could also put the tuple into an ordered container and have sorting done automatically.
Problem
I'm trying to just Order a list by the value after a split. For example my data looks like this. ``` Z|2 A|1 ``` I want my list to be order by the value after the split so I would get ``` A|1 Z|2 ``` This is what i'm using but I get the error: {"Input string was not in a correct format."} `All = All.OrderBy(s => int.Parse(s.Split('|')[1])).ToList();` Any help would be awesome! Thanks!