Edit in JSFiddle

var values = [0, 1, 5, 10, 15];
values.sort(); // 문자열 기준으로 정렬하기 때문에 5보다 10과 15가 앞선다
document.write(values +"<br>"); // 0,1,10,15,5 이러한 경우 compareFunction을 지정한다

function compare(value1, value2) {
	return value1 - value2;
}

values.sort(compare); // 비교함수를 통해 오름차순 정렬
document.write(values +"<br>"); // 0,1,5,10,15

//reverse() 메서드는 단순히 역순으로 뒤집는다.
values.reverse();
document.write(values +"<br>"); // 15,10,5,1,0