I have a list of objects
public class foo
{
public decimal val1 {get;set;}
public decimal val2 {get;set;}
}
I val1 and val2 can contain both negative or positive values.
if I have a List<foo>items is there a clean way I can sort them so that a negative value in either val1 or val2 are not the first or last item in the list.
My list size can very from 1 – 100. if it is less then 3 I do not need to sort. But if it is >= 3 I need to make sure any negative values are not first or last in the list.
You would try to push a “positive” value to the head and the tail of the list if they exist: