79755102

Date: 2025-09-03 21:40:27
Score: 1
Natty:
Report link
Public Shared Sub SortByPropertyName(propName As String)
    Dim prop = GetType(Person).GetProperty(propName)
    If prop Is Nothing Then Exit Sub

    If OrderAscending Then
        Person.Persons = Person.Persons.OrderBy(Function(x) prop.GetValue(x, Nothing)).ToList()
    Else
        Person.Persons = Person.Persons.OrderByDescending(Function(x) prop.GetValue(x, Nothing)).ToList()
    End If

    OrderAscending = Not OrderAscending
End Sub
Reasons:
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Polis Rabotas