Created
August 27, 2013 10:16
-
-
Save otf/6351849 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static int[] QuickSort(int[] arr) | |
{ | |
if (!arr.Any()) return new int[] { }; | |
var p = arr.First(); | |
var xs = arr.Skip(1); | |
var lesser = xs.Where(x => x < p).ToArray(); | |
var greater = xs.Where(x => x >= p).ToArray(); | |
return (QuickSort(lesser).Concat(new[] { p }).Concat(QuickSort(greater))).ToArray(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment