TypedArray.prototype.sort()

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

sort() 메서드는 적소에 형식화 배열의 요소를 정렬하여 그 형식화 배열을 반환합니다. 이 메서드는 Array.prototype.sort()와 같은 알고리즘입니다. TypedArray는 여기 형식화 배열 유형 중 하나입니다.

구문

js
typedarray.sort([compareFunction]);

매개변수

compareFunction Optional

정렬 순서를 정의하는 함수를 지정합니다.

더 많은 예는, Array.prototype.sort() 메서드도 참조하세요.

js
var number = new Uint8Array([40, 1, 5, 200]);

function compareNumbers(a, b) {
  return a - b;
}

numbers.sort(compareNumbers);
// Uint8Array [ 1, 5, 40, 200 ]

명세

Specification
ECMAScript Language Specification
# sec-%typedarray%.prototype.sort

브라우저 호환성

BCD tables only load in the browser

참조