What's the most elegant way to bubble-sort in C#?

后端 未结 10 1884
旧巷少年郎
旧巷少年郎 2020-12-06 03:33

Can this be cleaned up?

using System;  
class AscendingBubbleSort 
{     
    public static void Main()
    {
        int i = 0,j = 0,t = 0;
        int []c=         


        
10条回答
  •  被撕碎了的回忆
    2020-12-06 03:56

    The most elegant way to sort in C# is

    Array.Sort( object[] )
    

    That will work everywhere except in homework problems where the teacher asked you to implement the non-elegant bubble sort algorithm. ;-)

提交回复
热议问题