I have an object array that I add objects into (soda drinks). As I am now to build in also a method to remove specific objects from the array, I want to make sure that the objects are always placed before any empty spots in the array (sorting null to last).
How do I most efficiently sort nulls/empty spots to last in an array like this?
object[] bottleVector = new object[24];
// Constructor within class Sodacrate
class Soda
{
//CLASS VARIABLES
public string name;
public double price;
//CLASS CONSTRUCTOR
public Soda(string _name, double _price)
{
name = _name;
price = _price;
}
}
....
// Later in the code
public void add_soda()
{
//This is where I need help
bottles.Sort()
}