ahmed salah

ahmed salah

  • NA
  • 530
  • 148.8k

How to implement bubblesort inside main function

Dec 7 2016 10:42 AM
Hi I make function to bubble sort but i need to implement it inside
Main function as following :
  1.  class Program  
  2.     {  
  3.         static void Main(string[] args)  
  4. {  
  5. }  
  6. }  
How to implement bubblesort function inside Main function 
 and recieve number to implement it ?
  1. public List<int> bubblesort(List<int> a)  
  2. {  
  3. int temp;  
  4. // foreach(int i in a)  
  5. for(int i=1; i<=a.Count; i++)  
  6. for(int j=0; j<a.Count-i; j++)  
  7. if (a[j] > a[j + 1])  
  8. {  
  9. temp = a[j];  
  10. a[j] = a[j + 1];  
  11. a[j + 1] = temp;  
  12. }  
  13. return a;  
  14. }  
 

Answers (5)