public static IEnumerable <T> Choice <T>(T[] source, int k) { IndexList pastIndices = new IndexList(); for (int i = 0; i < k; i++) { int nextIndex = Rng.Next(source.Length - i); for (int j = 0; j < i; j++) { if (nextIndex >= pastIndices[j]) { nextIndex++; } } pastIndices.InsertSorted(nextIndex); yield return(source[nextIndex]); } }