ciao ragazzi.. è la prima volta che scrivo nel forum e lo faccio perchè avrei bisogno del vostro aiuto!
sto cercando di capire il funzionamento del linguaggio javascript (ho già sistemato qualche script preso qua e là) per sistemare il mio sito di fantacalcio..
bene.. oggi ho creato quasi dal nulla questa pagina www.legasalamandra.altervista.org/globale.htm !
tutto funziona perfettamente, tranne che non riesco ad ordinare la tabella in base all'ultimo valore!
questo è il codice che utilizzo! so che è scritto male e che potrebbe essere reso migliore, ma ciò che vorrei è che sopratutto funzionasse la funzione ordinatrice...

sapete aiutarmi??? grazie!

codice:
function Glob(Nome,Girone,Pos,Media,Pesata) {
	this.Nome = Nome
	this.Girone = Girone
	this.Pos = Pos
	this.Media = Media
	this.Pesata = Pesata
}


function ordina(a,b) {
          	if (a.Pesata>b.Pesata) return -1;
		if (a.Pesata<b.Pesata) return 1;
         	return 0;
}

function GeneraGlobale() {
var tabB = new Tabella(2,5)
var arrGlobale = new Array ()
var i,j,cnt,cut,m,n,w,f,x,y,z,jolly
	tabB.nome="globale"
	tabB.larghezza=50
	tabB.border=1
	tabB.cellpadding=3
	tabB.cellspacing=0
	tabB.stile="ClassEl"
	tabB.SetLarghezzaColonna(1,2)
	tabB.SetLarghezzaColonna(2,35)
	tabB.SetLarghezzaColonna(3,28)
	//tabB.SetLarghezzaColonna(4,20)
	tabB.SetLarghezzaColonna(4,20)
	tabB.SetLarghezzaColonna(5,20)
	
	tabB.SetStileRiga(1,"IntRossoBlu")
	tabB.SetStile(1,1,"CellaCentro")
	tabB.SetStile(1,2,"CellaCentro")
	tabB.SetStile(1,3,"CellaCentro")
	//tabB.SetStile(1,4,"CellaCentro")
	tabB.SetStile(1,4,"CellaCentro")
	tabB.SetStile(1,5,"CellaCentro")
	
	tabB.SetValore(1,1,"Pos.")
	tabB.SetValore(1,2,"Fantasquadra")
	tabB.SetValore(1,3,"Pos.Campionato")
	//tabB.SetValore(1,4,"Divisione")
	tabB.SetValore(1,4,"Media Tot.")
	tabB.SetValore(1,5,"Media Tot. Pesata")

var h = new Array ()
var k = new Array ()
			
	for(cnt=1;cnt<25;cnt++) {
k[cnt]=arrClassifica[cnt].TMed
}
m=(k[1]+k[2]+k[3]+k[4]+k[5]+k[6]+k[7]+k[8])/8
n=(k[9]+k[10]+k[11]+k[12]+k[13]+k[14]+k[15]+k[16])/8
w=(k[17]+k[18]+k[19]+k[20]+k[21]+k[22]+k[23]+k[24])/8

f=Math.max(m,n,w)
x=m/f
y=n/f
z=w/f


	for(cut=1;cut<25;cut++) {
if (arrClassifica[cut].IDGirone==1){h[cut]=(x);}
if (arrClassifica[cut].IDGirone==2){h[cut]=(y);}
if (arrClassifica[cut].IDGirone==3){h[cut]=(z);}

jolly = ((arrClassifica[cut].TMed)*h[cut])

var o = new Array ()
if(arrClassifica[cut].IDGirone==1){o[cut]=("Serie A")}
if(arrClassifica[cut].IDGirone==2){o[cut]=("Liga")}
if(arrClassifica[cut].IDGirone==3){o[cut]=("Premier League")}


arrGlobale[cut] = new Glob (arrClassifica[cut].Nome,o[cut],arrClassifica[cut].Pos,arrClassifica[cut].TMed,jolly)
}

//arrGlobale.sort(ordina)
//arrGlobale.sort(function (a,b) {
//return a.Pesata-b.Pesata
//})


	j=2
	for(i=1;i<arrGlobale.length;i++) {

if (arrGlobale[i].Girone=="Serie A") {
				sR="R"
			} else if (arrGlobale[i].Girone=="Liga") {
				sR="V"
			} else if (arrGlobale[i].Girone=="Premier League") {
				sR="Blu"
			} 

if ((j % 2) == 0) {
				tabB.SetStileRiga(j,"riga-dispari")
			} else {
				tabB.SetStileRiga(j,"riga-pari")
			}
	
			tabB.SetStile(j,1,"CellaCentro")
			tabB.SetStile(j,2,"Cella")
			tabB.SetStile(j,3,"CellaCentro")
			//tabB.SetStile(j,4,"CellaCentro")
			tabB.SetStile(j,4,"CellaCentro")
			tabB.SetStile(j,5,"CellaCentro")
			
			tabB.SetValore(j,1,"<span class='t-xxs"+sR+"'>"+i+"</span>")
			tabB.SetValore(j,2,"<span class='t-xxs"+sR+"'>[img]../img/fsq/class/"+arrGlobale[i].Nome+".png[/img]"+arrGlobale[i].Nome+"</span>")
			tabB.SetValore(j,3,"<span class='t-xxs"+sR+"'>"+arrGlobale[i].Pos+"° in "+arrGlobale[i].Girone+"</span>")
			//tabB.SetValore(j,4,"<span class='t-xxs"+sR+"'>"+arrGlobale[i].Girone+"</span>")
			tabB.SetValore(j,4,"<span class='t-xxs"+sR+"'>"+arrGlobale[i].Media+"</span>")
			tabB.SetValore(j,5,"<span class='t-xxs"+sR+"'>"+Math.round(((arrGlobale[i].Pesata)*1000))/1000+"</span>")
			

			j++
	}
	
		tabB.Stampa()
document.write("
")
document.write("<span class='t-xxsR'>Media Serie A: "+Math.round((m*1000))/1000+";</span><span class='t-xxsV'> Media Liga: "+Math.round((n*1000))/1000+"; </span><span class='t-xxsBlu'>Media Premier: "+Math.round((w*1000))/1000+"</span>
")
document.write("<span class='t-xxsB'>Media Max: "+Math.round((f*1000))/1000+"</span>
")
document.write("<span class='t-xxsR'>Coeff. Serie A: "+Math.round((x*1000))/1000+";</span><span class='t-xxsV'> Coeff. Liga: "+Math.round((y*1000))/1000+";</span><span class='t-xxsBlu'> Coeff. Premier: "+Math.round((z*1000))/1000+"</span>")


}