Source: AMAZON INTERVIEW QUESTION
Given a point P and other N points in two dimensional space, find K points
public static void NearestPoints() {
int[][] Points = { new int[] { -16, 5 },
new int[] { -1, 2 },
new int[] { 4, 3 },
new int[] { 10, -2 },
new int[] { 0, 3 },
new int[] {- 5, -9 } };
// Linq Order by default use quick sort which will be best suited in this.
var orderPoint = from i in Enumerable.Range(0, Points.Length)
orderby Math.Sqrt( Points[i][0] * Points[i][0]
+ Points[i][1] * Points[i][1] )
select new int[][] { Points[i] };
var result = orderPoint.Take(3);
}