.NET Fiddle

CSharp · Console

/Program.cs

using System;
using System.Linq;

public class Program
{
	public static void Main()
	{
		int[] list = [5, 2, 7, 3, 10, 8, 15, 65, 3, 5, 7, -1, 0, 10];
		var result = list.OrderBy(x => {
			Console.Out.WriteLine($"Foo({x})", x);
			return x.ToString();
		});
		Console.Out.WriteLine(string.Join(", ", result ));
	}
}
;