Hi. So I got two arrays where count[i] is the amount of times letter[i] appears.
let letters = ['a', 'e', 'i', 'o', 'u']; let count = [13, 24, 9, 11, 7];
Specifically, 'a' appears 13 times, 'e' 24 times, etc.
What I'm trying to do is to sort the count in a descending order an to do the same sort in letters array, in order to keep the relation. So I should get something like this:
letters = ['e', 'a', 'o', 'i', 'u']; count = [24, 13, 11, 9, 7];
I've been trying to do a bubble algorithm but I haven't been able to write it in code, however this way is not really time efficient due the large array I got (code is simplified), is still better than nothing. Anyway, I'd appreciate any help in developing the algorithm or an efficient way to do this. All this is because I need to get the 3 letters that appear more often, so then I'd do something like:
$w('#text1').text = count.toString(); // 24 $w('#text2').text = letter; // e $w('#text3').text = count.toString(); // 13 $w('#text4').text = letter; // a $w('#text5').text = count.toString(); // 9 $w('#text6').text = letter; // o