Here is a code to sort numbers instead of strings using the BubbleSort method. The difference here is you don't use compareTo() for numbers as you do with strings.
Sort numbers
public class SortArrayNumbers
{
public static void sortEm(int [] array, int len)
{
int a,b;
int temp;
int sortTheNumbers = len - 1;
for (a = 0; a < sortTheNumbers; ++a)
{
for (b = 0; b < sortTheNumbers; ++b)
if(array[b] < array[b + 1])
{
temp = array[b];
array[b] = array[b + 1];
array[b + 1] = temp;
}
}
}
}
alpe gulay -1 Light Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.