Help: Bubble sorting problem.

Hello boys and girls! 

 

I'm currently working on how bubble sorting works and this is what I have:

 using System; namespace bubbleSort_array { class Bubble_sort_test { static void Main() { int[] letters = { 'c', 's', 'a', 'k', 'x', 'l', 'j' }; int temp = 0; for (int write = 0; write < letters.Length; write++) { for (int sort = 0; sort < letters.Length - 1; sort++) { if (letters[sort] > letters[sort + 1]) { temp = letters[sort + 1]; letters[sort + 1] = letters[sort]; letters[sort] = temp; } } } for (int i = 0; i < letters.Length; i++) Console.Write(letters[i] + " "); Console.ReadKey(); } } } 

But for some reason when I write it to the console, it takes my letters and makes them to numbers.  I can see that my sorting works but getting numbers isn't exactly what I want.  I'm pretty sure that I'll need to put in Char somewhere but I have a problem which I can't really see where to use it.  I would appreciate if I could get some help with this as I'm a beginner with C#.  Thanks for your patience.

by a_nice_function via /r/csharp

Leave a Reply