“String Sort JavaScript” Respostas de código

Javascript Order by String Array

users.sort((a, b) => a.firstname.localeCompare(b.firstname))
Motionless Macaque

String de pedido js

// function that returns a string in alphabetical order
function reorderStr(str) {
	return [...str].sort().join('');
}
console.log(reorderStr("hacker"));	//"acehkr"
console.log(reorderStr("javascript"));//"aacijprstv"
Lucky-Magnet

classificar por javascript ascendente

const months = ['March', 'Jan', 'Feb', 'Dec'];
months.sort();
console.log(months);
// expected output: Array ["Dec", "Feb", "Jan", "March"]
Open Otter

String Sort JavaScript

var names = ["Peter", "Emma", "Jack", "Mia"];
var sorted = names.sort(); // ["Emma", "Jack", "Mia", "Peter"]
TC5550

Respostas semelhantes a “String Sort JavaScript”

Perguntas semelhantes a “String Sort JavaScript”

Procure respostas de código populares por idioma

Procurar outros idiomas de código