How to sort a List
which holds values as mentioned below
67.232,S
98.122,F
12.211,H
and so ..
Now I need to sort the above List
value like
12.211,H
67.232,S
98.122,F
Initially I tried with below piece of code (which I got from Sorting a List of Strings numerically (1,2,...,9,10 instead of 1,10,2))
Position.Add(25.251,A);
Position.Sort((x, y) => ExtractNumber(x).CompareTo(ExtractNumber(y)));
static int ExtractNumber(string text)
{
Match match = Regex.Match(text, @"^[^,]*");
if (match == null)
{
return 0;
}
int value;
if (!int.TryParse(match.Value, out value))
{
return 0;
}
return value;
}
but its not working out for me Can anyone help me out please
Thanks