I have always been attracted by the magic of functional programming. I have been very interested in the features of dynamic languages and have learned how to simplify programming by using lambda calculus, now I want to list a function-based quick sorting that I have been thinking for a long time.
/// <Summary>
/// Quick sorting Function
/// </Summary>
/// <Typeparam name = "T"> </typeparam>
/// <Param name = "list"> </param>
/// <Returns> </returns>
Ienumerable < T > Quicksorting < T > (Ienumerable < T > List) Where T: icomparable < T >
{
If (List. Count () <= 1 ) Return List;
VaR callback = List. First ();
Return Quicksorting (list. Where (x => X. compareto (bytes) < 0 ))
. Concat (list. Where (x => X. compareto (bytes) = 0 ))
. Concat (quicksorting (list. Where (x => X. compareto (bytes) > 0 )));
}
Test method:
Static Void Main ( String [] ARGs)
{
List < Int > Ints = New List < Int >
{
22 , 33 , 11 , 43 , 55 , 123 , 452 , 1 , 3 , 5 , 15 , 153 , 10000 , 532 , 553 , 22 , 33 , 11 , 53 , 11 , 33
};
List < Int > Lists = New Program (). quicksorting < Int > (Ints). tolist < Int > ();
Lists. foreach ( => Console. writeline ());
}
Test results:
Correct ............!!
Dear reader ...... Do you understand ......