compare(par,desc){ return function(a,b){ var value1 = a[par]; var value2 = b[par]; if(desc == true){ return value1 - value2}else{return value2-value1} } }