Sort them in ascending order:
1. bubble sort source code:
Java code
Float [] scores = {0.0f, 2.0f, 3.0f, 1.0f };
// Define temporary variables
Float temp = 0.0f;
// Perform Bubble Sorting: I controls the number of rounds to compare and j controls the number of times to compare each round.
For (int I = 0; I <scores. length-1; I ++ ){
For (int j = 0; j <scores. length-1-I; j ++ ){
If (scores [j]> scores [j + 1]) {
Temp = scores [j];
Scores [j] = scores [j + 1];
Scores [j + 1] = temp;
}
}
}
2. Select the sorting source code:
Java code www.2cto.com
Float [] scores = {0.0f, 2.0f, 3.0f, 1.0f };
// Define temporary variables
Float temp = 0.0f;
// Locate the minimum Index
Int min;
For (int I = 0; I <scores. length-1; I ++ ){
Min = I;
For (int j = I + 1; j <scores. length; j ++ ){
If (scores [j] <scores [min]) {
Min = j;
}
}
If (min! = I ){
Temp = scores [min];
Scores [min] = scores [I];
Scores [I] = temp;
}
}
Author: loseinworld