Go Back   Computer Forums > General Computing > Programming
Join Computer forums Today

Thread Tools Search this Thread Display Modes
Old 04-20-2006, 07:47 PM   #11
Baseband Member
Bozorg's Avatar
Join Date: Mar 2006
Posts: 34
Send a message via AIM to Bozorg Send a message via MSN to Bozorg
Default Re: Some JAVA help, please?

I guessing that you have the team names in one array in the same spot as the scores in the array for intance teamA[0] goes with scores[0].

I would use a sort loop like this.
int p; //position of the lowest score
int tempScores;
String tempTeams;
for(int i=0; i < scores.length; i++){
int min = 50; //set this to some high number that the wins would never be
for(int x = i; x < scores.length; x++){
if(scores[x]< min){
min = scores[x];
p = x;
tempScores = scores[i];
tempTeams = teamsA[i];
scores[i] = scores[p];
teamsA[i] = teamsA[p];
scores[p] = tempScores;
teamsA[p] = tempTeams;

You will need to figure out how to read from your file and put the scores in an int array rather than a String array.

Of course this is not really efficient but it works.

I havent tested this code I just wrote it from the top of my head.
Let me know if it helps

Bozorg is offline   Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

All times are GMT -5. The time now is 11:12 PM.

Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2016, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0