server side sort


  • se si dispone di db, si può utilizzare SELECT ... SORT BY
    spesso è veloce come il codice e, a volte, di più
  • oppure un semplice algoritmo:
    dim matrix(5),i,j,temp
    matrix(1) = 50
    matrix(2) = 70
    matrix(3) = 120
    matrix(4) = 30
    matrix(5) = 80
    
    for i = 1 to 5
    for j = i to 5
    	if matrix(i) < matrix(j) then
    		temp = matrix(i)
    		matrix(i) = matrix(j)
    		matrix(j) = temp
    	end if
    next
    next