Program to sort a list of numbers generated randomly. public

class SortNumbers {
public static void sort(double[] nums) {
for(int i = 0; i < nums.length; i++) {
int min = i; // holds the index of the smallest element
// find the smallest one between i and the end of the array
for(int j = i; j < nums.length; j++) {
if (nums[j] < nums[min]) min = j;
}
// Swaping being done using the third variable tmp.
double tmp;
tmp = nums[i];
nums[i] = nums[min];
nums[min] = tmp;
}
}

public void work(){
double[] nums = new double[10]; // Create an array to hold numbers
for(int i = 0; i < nums.length; i++) // Generate random numbers
nums[i] = Math.random() * 100;
sort(nums); // Sort them
for(int i = 0; i < nums.length; i++) // Print them out
System.out.println(nums[i]);
}
}