It's not necessary to sort a list to find the Min/Max value from a list. The best sorting algorithm has an average complexity of O(N*logN). Both Max and Min operations shouldn't take more than O(N), even though the list is unsorted.
You can implement the solution posted here or implementing the following code:
private static Employee MaxBySalary(List<Employee> employees)
{
Employee employee = null;
employees.ForEach(x => employee = ( employee != null && employee.Salary > x.Salary) ? employee : x );
return employee;
}
private static Employee MinBySalary(List<Employee> employees)
{
Employee employee = null;
employees.ForEach(x => employee = (employee != null && employee.Salary < x.Salary) ? employee : x);
return employee;
}
Both approaches have O(N) complexity