If I have some list of strings contain all numbers and dashes they will sort ascending like so:
s = s.OrderBy(t => t).ToList();
66-0616280-000
66-0616280-100
66-06162801000
66-06162801040
This is as expected.
However, if the strings contain letters, the sort is somewhat unexpected. For example, here is the same list of string with trailing A's replacing the 0s, and yes, it is sorted:
66-0616280-00A
66-0616280100A
66-0616280104A
66-0616280-10A
I would have expected them to sort like so:
66-0616280-00A
66-0616280-10A
66-0616280100A
66-0616280104A
Why does the sort behave differently on the string when it contains letters vs. when it contains only numbers?
Thanks in advance.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…