I have a requirement to sort some strings that contain data like this:
var strings = new List<string>{"2009 Arrears","2008 Arrears","2008 Arrears Interest","2009 Arrears Interest"};
And they want the results ordered like this:
- "2009 Arrears"
- "2009 Arrears Interest"
- "2008 Arrears"
- "2008 Arrears Interest"
It seems like I need to create a function to see if the string starts with a number. If so, the function will get all numbers up until the first character and sort the numeric result descending and then sort the remaining characters ascending. I am having trouble trying to write a method that gets all starting numbers in a string. What would be an efficient way to do that?