If I understand this correctly you have an object (say, Parent) which contains an object (say, Child). Child has a field FullName and you want to sort a list of parents by the child FullName.
If so, then then OrderBy() should do it for you.
Say we have a list of parents
Parent{ Id = 1, Child = { Id = 1, FullName = "Jan"}}
Parent{ Id = 2, Child = { Id = 2, FullName = "Feb"}}
Parent{ Id = 3, Child = { Id = 3, FullName = "Mar"}}
Parent{ Id = 4, Child = { Id = 4, FullName = "Apr"}}
sorting them using OrderBy()
Dim sorted = Items.OrderBy(Function(itm) itm.Child.FullName)
gives
Parent{ Id = 4, Child = { Id = 4, FullName = "Apr"}}
Parent{ Id = 2, Child = { Id = 2, FullName = "Feb"}}
Parent{ Id = 1, Child = { Id = 1, FullName = "Jan"}}
Parent{ Id = 3, Child = { Id = 3, FullName = "Mar"}}
(example below)
hth,
Alan.
Edit
Just re-read the question. You have different FullName properties which are selected by name (from a query string?)
You can select the property by name using an expression (see, How can I create a dynamic Select on an IEnumerable<T> at runtime?) for the general shape.
If the selected property is IComparable (Or is it IEquatable? Not too sure which) then the OrderBy() will still work. This means that as long as the sort fields are basic types you are fine. If they are custom types (objects) you will need to do some more work...
Sorry about the first mis-answer.
More Edits
It's Friday and slow in here :?
OK, expanded the answer to access different child memebers by name. (I used Fields rather than Properties but either will work). We still need to know the type of the field but a bit more work might remove that (if needed).
Private Class Child
Public Id As Integer
Public FullName As String
End Class
Private Class Parent
Public Id As Integer
Public Child As Child
End Class
Private Items As New List(Of Parent)() From { _
New Parent() With { _
Key .Id = 1, _
Key .Child = New Child() With { _
Key .Id = 1, _
Key .FullName = "Jan" _
} _
}, _
New Parent() With { _
Key .Id = 2, _
Key .Child = New Child() With { _
Key .Id = 2, _
Key .FullName = "Feb" _
} _
}, _
New Parent() With { _
Key .Id = 3, _
Key .Child = New Child() With { _
Key .Id = 3, _
Key .FullName = "Mar" _
} _
}, _
New Parent() With { _
Key .Id = 4, _
Key .Child = New Child() With { _
Key .Id = 4, _
Key .FullName = "Apr" _
} _
} _
}
<TestMethod> _
Public Sub SortByChildName()
Dim expectedParentIds = New () {4, 2, 1, 3}
Dim sortedIds = Items.OrderBy(SelectExpression(Of Parent, String)("Child.FullName")).[Select](Function(itm) itm.Id)
Assert.IsTrue(expectedParentIds.SequenceEqual(sortedIds))
End Sub
<TestMethod> _
Public Sub SortByChildId()
Dim expectedParentIds = New () {4, 3, 2, 1}
Dim sortedIds = Items.OrderBy(SelectExpression(Of Parent, Integer)("Child.Id")).[Select](Function(itm) itm.Id)
Assert.IsTrue(expectedParentIds.SequenceEqual(sortedIds))
End Sub
Public Shared Function SelectExpression(Of TItem, TField)(fieldNames As String) As Func(Of TItem, TField)
Dim type = GetType(TItem)
Dim fields = fieldNames.Split("."C)
Dim arg As ParameterExpression = Expression.Parameter(type, "item")
Dim expr As Expression = arg
For Each field As String In fields
Dim fieldInfo = type.GetField(field)
expr = Expression.Field(expr, fieldInfo)
type = fieldInfo.FieldType
Next
Return Expression.Lambda(Of Func(Of TItem, TField))(expr, arg).Compile()
End Function