Sort uses a built-in sorting method (uses the QuickSort algorithm) where given the list of items to sort, it uses the method you pass to it to determine which item goes first.
So for example, say I had a list of integers that I needed to sort, it might be as simple as:
private bool IntCompare(int value1, int value2)
{
if (value1 < value2)
{
return -1;
}
else if (value1 == value2)
{
return 0;
}
else
{
return 1;
}
}
int[] list = new int[]{1,9,3,5,2,6};
list.Sort(IntCompare);
In this case, Unity automatically performs the sorting, but does so according to the rules you setup in “IntCompare”. (return -1 means “value1” comes before “value2”, 0 means they’re equal, 1 means “value1” comes after “value2”)
In C#, referencing methods like that is done using “delgates”. The code you posted is just a short-hand way of creating delegates. In my first example, I declared a full class member for the sorting. But it could just as easily be rewritten using an anonymous method (a method that doesn’t strictly belong to a class):
int[] list = new int[]{1,9,3,5,2,6};
list.Sort(delegate(int value1, int value2)
{
if (value1 < value2)
{
return -1;
}
else if (value1 == value2)
{
return 0;
}
else
{
return 1;
}
}
);
So these are useful when you want to apply special sorting rules for special objects (sort your transforms in order to say, an arbitrary central point. Sort them by their magnitude. Or whatever)
It’s late, so hopefully I didn’t put much misinformation/mistakes in that. Hopefully that’ll help you out.