First off let's address your specific problems. The array size should be two, not one; a multidimensional array with one dimension sized to one doesn't make much sense.
int[,] values = new int[50,2];
Next, how do you initialize this array in a loop?
for (int i = 0; i<Oranges; i++)
values[i,0]={functionCall(),i};
This is illegal because the { }
syntax can only be used in an array initializer. Instead you mean to say:
for (int i = 0; i < 50; i++)
{
values[i,0]= functionCall();
values[i,1]= i;
}
Next, how do you sort the array?
You don't. Multidimensional arrays are hard to sort and there are few tools for doing so. You'd have to write your own sort algorithm to do it in place.
Since that is the goal and we are now frustrated, we should take a step back and reconsider whether a 2-d array is the correct data structure. It isn't. Here's the right way to solve your problem:
struct Pair<T>
{
public T First { get; private set; }
public T Second { get; private set; }
public Pair(T first, T second) : this()
{
First = first;
Second = second;
}
}
...
static IEnumerable<Pair<int>> Pairs()
{
int i = 0;
while(true)
{
yield return new Pair<int>(functionCall(), i);
i = i + 1;
}
}
...
List<Pair<int>> pairs =
Pairs()
.Take(50)
.OrderBy(p=>p.First)
.ToList();
And now we have a sorted list of fifty pairs of ints, which is what you wanted. Moreover, it is extremely clear from the code that we have a sorted list of fifty pairs of ints.
Here is an alternative solution which uses the "select with index" feature that I like a bit better:
static IEnumerable<int> Values()
{
while(true)
yield return functionCall();
}
...
List<Pair<int>> pairs =
Values()
.Take(50)
.Select((item, index)=>new Pair<int>(item, index))
.OrderBy(p=>p.First)
.ToList();
When you use data structures that represent the shape of your data accurately and use sequence operators on sequences, life gets easier.