LINQ QuickSort in C#

This is most certainly not the recommended way of implementing QuickSort, it assumes there are no duplicates, but it should work:

        private IList<int> sort(IList<int> a)
        {
            if (a.Count <= 1)
                return a;
            return sort(a.Where(x => x < a[0]).ToList()).Union(new List<int> { a[0] }).Union(sort(a.Where(x => x > a[0]).ToList())).ToList();
        }

It's a nice demonstration of how C# is getting closer to resemble a proper lambda-oriented functional language.

Hah. Nice to know there are

Hah. Nice to know there are other people that do too many things in LINQ one liners. :P

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
Please confirm you are a human being
Image CAPTCHA
Enter the characters shown in the image.