これを機能させることができません。何をしても正しくソートされないようです。
ポイント数に基づいて降順に並べ替えようとしています。
Bryan_Bickell 2 5 +2
Brandon_Bolig 0 3 0
Dave_Bolland 4 2 -1
Sheldon_Brookbank 0 4 -1
Daniel_Carcillo 0 1 +3
真ん中の列はポイント数です。
これらの値をすべて格納するために 4 つの配列を使用していますが、配列選択ソートを正しく利用して正しい方法で並べ替えるにはどうすればよいでしょうか?
以下のすべての答えを試しましたが、どれもうまくいかないようでした。これが私がこれまでに持っているものです
void sortArrays( string playerNames[], int goals[], int assists[], int rating[], int numPlayers )
{
int temp, imin;
int points[numPlayers];
for(int j = 0; j < numPlayers; j++)
{
points[j] = goals[j] + assists[j];
}
imin = points[0];
for(int i = 0; i < numPlayers; i++)
{
if (points[i] < imin)
{
imin = points[i];
}
}
for(int j = 1; j < numPlayers; j++)
{
if (points[j] > imin)
{
temp = points[j];
points[j] = points[j-1];
points[j-1] = temp;
}
}
}