Help with debugging a code: expected ';' before beats

Hey there can anyone help me figure out why

It keeps saying expected ‘;’ before beats

int getBPM(){
int dummy; // used in sorting
int mean; // used in averaging
boolean done = false; // clear sorting flag
// this simple sorting routine will arrange values in the beat array from lowest to highest
while(done != true){
done = true;
for (int j=0; j beats[j + 1]){ // sorting numbers here
dummy = beats[j + 1];
beats [j+1] = beats[j];
beats[j] = dummy;
done = false;

And here is the Error message that i got:

sketch_apr02c.ino: In function ‘int getBPM()’:
sketch_apr02c:133: error: expected `;’ before ‘beats’
sketch_apr02c.ino: At global scope:
sketch_apr02c:142: error: expected unqualified-id before ‘for’
sketch_apr02c:142: error: ‘k’ does not name a type
sketch_apr02c:143: error: expected declaration before ‘}’ token

I think you need a third parameter here:

for (int j=0; j beats[j + 1]){ // sorting numbers here

for (start_condition; end_condition; condition_change){

The while part of your for loop is:

j beats[j + 1]

What is that supposed to mean/do?

Usually, you’d have something like j<beats[j+1]. Though that doesn’t look right, either.

Perhaps the best thing to do is explain what you are trying to do. The loop you have now does not sort anything.

It seems pointless guessing what might be wrong with your code until you post it (preferably the whole sketch not just a snippet) in [ code ] [ /code ] tags. Otherwise, the forum software will munge your code.

You can fix that now by editing your post, selecting the source code and clicking the # button in the edit window.