Skip to content

Instantly share code, notes, and snippets.

View foliveira's full-sized avatar
👨‍💻
I may be slow to respond.

Fábio Oliveira foliveira

👨‍💻
I may be slow to respond.
View GitHub Profile
@foliveira
foliveira / LazyQsort.cs
Created June 28, 2011 16:22 — forked from duarten/LazyQsort.clj
A lazy quick sort
public static IEnumerable<T> LazyQsort<T>(IEnumerable<T> seq, Func<T, T, bool> comp)
{
if (seq.Any() == false)
{
return Enumerable.Empty<T>();
}
var pivot = seq.First();
var xs = seq.Skip(1);
return LazyQsort(xs.Where(x => comp (x, pivot)), comp)