CSharp · Console
using System;
using System.Linq;
public class Program
{
public static void Main()
{
double[] arr = { 2.1, 70.1, 15.1, 92.1, 105.1, 65.1, 40.1, 9.1, 22.1 };
int n = 3;
double[] result = arr.OrderByDescending(x=>x).ToArray();
//Result will contais {105, 92, 70, 65, 40, 22, 15, 9, 2}
//More readable to newbie
Console.WriteLine("Top {0} elements from Array", n);
for(int i = 0; i < n; i++)
{
Console.Write(result[i]+" ");
}
}
}