var arr=[2,6,10,3,9,1,0]; arr=arr.sort(sortFunction); alert(arr[arr.length-1]); function sortFunction(a, b){ return a-b; };