My code is bellow and I have attached the text file to run on it but I need it to sort the numbers from highest to lowest
baseballinput.txt
package baseball;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
import java.util.Arrays;
import java.util.Collections;
public class baseball {
public static void main(String[] args) throws FileNotFoundException
{
String firstName = "";
String lastName = "";
int hits = 0;
int walks = 0;
int caughtStealing = 0;
int stolenBases = 0;
int atBats = 0;
int totalBases = 0;
double runsCreated = 0.0;
double[] runsCreatedList = new double [40];
double[] sortList = new double [40];
String[] nameList = new String[40];
Scanner console = new Scanner(System.in);
//Asks user for input file name
//If the file is stored on your desktop it will be something like:
// C:\Users\Nick\baseballinput.txt
System.out.println("Input File Name: ");
String inputFileName = console.next();
//inputFile will take input from stored input file
File inputFile = new File(inputFileName);
//in will take input from user defined source
Scanner in = new Scanner(inputFile);
while(in.hasNext())
{
for (int i= 0 ; i<= 39; i++)
{
lastName = in.next();
firstName = in.next();
hits = in.nextInt();
walks = in.nextInt();
caughtStealing = in.nextInt();
stolenBases = in.nextInt();
atBats = in.nextInt();
totalBases = in.nextInt();
runsCreated = ((double)(hits + walks - caughtStealing ) * (totalBases + (.55 * stolenBases ))/(double)(atBats + walks ));
runsCreatedList[i] = runsCreated;
sortList[i] = runsCreated;
nameList[i] = firstName +" "+lastName;
}
}
//sort list here
for(int j = 0; j <= 39; j++)
{
for(int m = 0; m <= 39; m++)
{
if(runsCreatedList[m] == sortList[j])
{
System.out.print(nameList[m] + ": "+ runsCreatedList[m] + "\n");
}
}
}
in.close();
}
}