
function SetHighScore
{
	if(IsReplay){return;}
	score=GetCommonData("Score");
	let table=gamemode*10;
	if(menu_playstage==10){table=30;}
	if(memory_highscore[table+9]<score)
	{
		memory_highscore[table+9]=score;
		memory_highscore_stage[table+9]=stagenum;
		let a=table+9;
		while(a>table)
		{
			if(memory_highscore[a-1]<memory_highscore[a])
			{
				let w=memory_highscore[a-1];
				memory_highscore[a-1]=score;//memory_highscore[a];
				memory_highscore[a]=w;
				
				w=memory_highscore_stage[a-1];
				memory_highscore_stage[a-1]=stagenum;//memory_highscore_stage[a];
				memory_highscore_stage[a]=w;
			}
			else{break;}
			a--;
		}
	}
	

	SetCommonData("Memory_HighScore",memory_highscore);
	SetCommonData("Memory_HighScore_Stage",memory_highscore_stage);
}
