I have this list called “Block”. Each item has four parts being a string called “block”, and three floats for each coordinate:
public class Block : IComparable<Block>
{
public string block;
public float xLocation;
public float yLocation;
public float zLocation;
public Block (string newBlock, float newXLocation, float newYLocation, float newZLocation)
{
block = newBlock;
xLocation = newXLocation;
yLocation = newYLocation;
zLocation = newZLocation;
}
}
I want to order the blocks first by lowest x value, then lowest y value, and finally lowest z value.
So if I had this in the list:
- “Stone”, -20, 30, 15
- “Slope”, -20, 20, 50
- “Stone”, 40, 5, 0
- “Slope”, -20, 20, 10
It would end up like this:
- “Slope”, -20, 20, 10
- “Slope”, -20, 20, 50
- “Stone”, -20, 30, 15
- “Stone”, 40, 5, 0
Try to keep in mind I’m still not that good at Unity so if you can, try to provide some explanation on what the code is doing. Also I prefer C#.
Thanks in advance!