How to sort elements of an array using nested for-loops?
问题 I'm taking on a programming challenge for practice and I'm having trouble figuring this one out. It might be due to the time and my current sleepiness, but I want to get this done before bed. I want to sort the values of each element of an array in ascending order. The trick is not to use a sort() method. Here is what I have so far: for (int i = 0; i < freq_array.Length; i++) { for (int n = 1; n < i; n++) { if (freq_array[n] < freq_array[i]) freq_array[i] = freq_array[n]; } } for (int x = 0;