I'd suggest to wite helper-class, for example:
public static class StringHelper
{
public static int ToNumeric(string value)
{
int retval = Int32.MinValue;
Int32.TryParse(value, out retval);
if(value==null && retval==0) retval = Int32.MaxValue;
return retval;
}
public static string TypeName(string value)
{
string sName = string.Empty;
int tmp = ToNumeric(value);
if (tmp == Int32.MaxValue)
sName = "A";
else if(tmp==0)
sName = "C";
else
sName = "B";
return sName;
}
}
Now, you can write query:
List<string> myValues = new List<string>(){"123","562","d586","5",null,"689","a896"};
var sortedList = myValues
.OrderByDescending(x => StringHelper.TypeName(x))
.ThenByDescending(x => StringHelper.ToNumeric(x))
.ToList();
Result:
d586
a896
689
562
123
5
null
Note: you have to improve that, because i'm bit busy today and won't assign more time over it.