1

I am using this program as an example which sort these arrays according to "b".

int[] a = { 5, 2, 3 }; 

int[] b = { 4, 1, 2 };

string[] c = { "John", "Peter", "Max" };

Array.Sort(b.ToArray(), c);

Array.Sort(b.ToArray(), a);

Array.Sort(b);

Console.WriteLine(string.Join(", ", a));

Console.WriteLine(string.Join(", ", b));

Console.WriteLine(string.Join(", ", c));

The Result is:

2, 3, 5

1, 2, 4

Peter, Max, John

I want to make the result appear vertically for e.g.

2    1    Peter

3    2    Max

5    4    John
1
  • please use code tags Commented Mar 29, 2016 at 18:58

2 Answers 2

2

With that structure you'll need to loop and use the array indexer:

for(int i=0; i < a.Length; i++)
{
    Console.WriteLine("{0} {1} {2} ", a[i], b[i], c[i]);
}
Sign up to request clarification or add additional context in comments.

Comments

0
Console.WriteLine(string.Join(Environment.NewLine,
    Enumerable.Range(0, a.Length)
    .Select(i => string.Format("{0} {1} {2}", a[i], b[i], c[i]))));

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.