today I just tried out the LINQ-Framework and wondered if there is a way doing the following. I have a list of adresses which contain a streetname and a housenumber. First I list all adresses based on thier streetnames by
list = list.OrderBy(x => x.StreetName)
If the streetnames are equal I want to compare the housenumbers as well using the ThenBy
-expression, but here is the problem as the housenumber may consist of two parts: an integer (e.g. 12) and a string-suffix (e.g. A) which results in 12A. So I want to sort the list on the housenumber (the int value) and afterwards the suffix (the string value) as well. I also created the regex to split housenumber into int- and string value, so that´s not the problem, here is it: (\d+) *(\S)*
but I come not across to get these two values (in some cases there´s only one as there is no suffix) to the sorting of LINQ as well.
I there any way of doing this?