I have a alphanumeric string of array which contains some characters at end of string also. The problem is i'm able to sort only till before the last character. Here is the my array
string[] ar = new string[] { "DV00154A", "DV00144A", "DV00111B", "DV00100A", "DV00199B", "DV00001A" };
i have tried some method but the sorted array skipping the sorting of last character. here is one of the approach which i have tried.
public static string ArraySort(string input)
{
return Regex.Replace(input, "[0-9]+", match => match.Value.PadLeft(10,'0'));
}
public static void Main(string[] args)
{
string[] ar = new string[] { "DV00154A", "DV00144A", "DV00111B", "DV00100A",
"DV00199B", "DV00001A" };
var result = ar.OrderBy(x => ArraySort(x));
Console.WriteLine(string.Join(",",result.ToArray()));
}
which returning the below output
DV00001A,DV00100A,DV00111B,DV00144A,DV00154A,DV00199B
but the output i need should be like this
DV00001A,DV00100A,DV00144A,DV00154A,DV00111B,DV00199B