You have to tell the compiler that you’re declaring a generic function, otherwise it will assume that T is a type you’ve defined somewhere else. By using the < T > syntax you’re telling the compiler that T is a stand-in for an actual type that will have to be figured out whenever the function is used.
It doesn’t even have to be T, it can be any identifier. You can also do multiple types, e.g…
void SomeGenericFunction<X, Y>(X value1, Y value2)...
Without the angle brackets, the compiler will see…
void SomeGenericFunction(X value1, Y value2)...
And will give you an error unless you’ve defined the data types X and Y.
Back to your original function, when you call it you can specify the generic type…
int[] myIntArray...
RandomizeArray<int>(myIntArray)...
Or if the compiler can figure out the data type you can just pass it in…
RandomizeArray(myIntArray)...
And one final thing, in your function you’re using GameObject during the swap. You should be using T instead, so instead of
GameObject tmp = array[randomIndex];
You should use
T tmp = array[randomIndex];
if that makes sense. And one last thing, you need to return the sorted array at the end.