A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developer.mozilla.org/pt-BR/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/sort below:

TypedArray.prototype.sort() - JavaScript | MDN

TypedArray.prototype.sort()

Baseline Widely available

O método sort() ordena os elementos de uma matriz tipada no local e retorna a matriz ordenada. Esse método tem o mesmo algoritmo que Array.prototype.sort(). TypedArray é uma das maneiras de escrever matrizes.

Syntax
typedarray.sort([compareFunction])
Parâmetros
compareFunction Optional

Especifica uma função que define a ordem de classificação.

Valor de retorno

A matriz ordenada.

Exemplos

Para mais exemplos, acesse o método Array.prototype.sort().

var numbers = new Uint8Array([40, 1, 5, 200]);
numbers.sort();
// Uint8Array [ 1, 5, 40, 200 ]
// A compare function is not required as in the case of Array
// to sort the numbers numerically.

var numbers = [40, 1, 5, 200];
numbers.sort();
// The elements are sorted as strings.
// [1, 200, 40, 5]

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

numbers.sort(compareNumbers);
// [ 1, 5, 40, 200 ]
Especificações Compatibilidade com navegadores Ver também

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4