I need to know where I am going wrong with this.

I get it to run but I can't get it to sort.

package CSCI; public class RandomArray { /** The method for sorting the numbers */ public static void bubbleSort(int[] randomNums) { boolean needNextPass = true; for (int k = 1; k < randomNums.length; k++) { // Array may be sorted and next pass not needed needNextPass = false; for (int i = 0; i < randomNums.length - k; i++) { if (randomNums[i] > randomNums[i + 1]) { // swap list[i] with list[i + 1] int temp = randomNums[i]; randomNums[i] = randomNums[i + 1]; randomNums[i + 1] = temp; needNextPass = true; // Next pass still needed } } } } public static void main(String[] args) { int [] randomNums = new int [20]; for (int i = 0; i < randomNums.length; i++){ randomNums[i] = (int) (100 * Math.random()); } for (int i = 0; i < randomNums.length; i++) { System.out.print(randomNums[i]+ ","); } } }

This post has been edited by **madkidz**: 06 May 2008 - 03:40 PM