public List <ContainerCooled> getContainersCooledSorted(List <IContainer> containers) { List <IContainer> clonedList = new List <IContainer>(containers); List <ContainerCooled> sortedList = new List <ContainerCooled>(); foreach (ContainerCooled container in containers.OfType <ContainerCooled>()) { ContainerCooled maxContainerCooled = getMaxWeightContainerCooled(clonedList); sortedList.Add(maxContainerCooled); clonedList.Remove(maxContainerCooled); } return(sortedList); }
public ContainerCooled getMaxWeightContainerCooled(List <IContainer> containers) { int maxWeight = 0; ContainerCooled maxWeightContainer = null; foreach (ContainerCooled container in containers.OfType <ContainerCooled>()) { if (container.weight > maxWeight) { maxWeightContainer = container; maxWeight = container.weight; } } return(maxWeightContainer); }