I am trying to make a PEN that takes names and ratings, sorts the 2 arrays based on the ratings, using Bubblesort and displays the sorted arrays. But it doesn’t seem to work for numbers greater or equal than 10 (tried 9.99 and it works but not with 10.001 or 10). Here’s the code:
for (var i = numberOfCountries -1; i>=0; i-- ){
for (var j = 0; j <= i; j++){
if (ratings[j-1] < ratings[j]){
var temp = ratings[j-1];
ratings[j-1] = ratings[j];
ratings[j] = temp;
temp = countries[j-1];
countries[j-1] = countries[j];
countries[j] = temp;
}
}
}