Sort by other list

CSharp · Console

/Program.cs

using System;
using System.Drawing;
using System.Linq;
using System.Collections.Generic;

public class ListClass 
{
	public ListClass(int x, int y)
	{
		X = x;
		Y = y;
	}
	public int X { get; set; }
	public int Y { get; set; }
}
public class Program
{
	public static void Main()
	{

		var listA = new int [] {5,4,1,2,7,3,8,6};
		var listB = new List<ListClass>
		{
			new ListClass(1,20),
			new ListClass(4,11),
			new ListClass(7,5)
		};
		var results = listB.OrderBy
			(
				p => Array.IndexOf(listA, p.X)
			);
		foreach (var r in results) Console.WriteLine("{0},{1}", r.X, r.Y);
		
	}
}
;