Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

sort javascript number array with duplicates

//ascending order
console.log([1, 2, 0, 1].sort((a, b) => a - b))

//descending order
console.log([1, 2, 0, 1].sort((a, b) => b - a))
 Run code snippetHide results
Comment

PREVIOUS NEXT
Code Example
Javascript :: mongoose ensureindex 
Javascript :: ternary operator online 
Javascript :: package json replace to dev dependencies 
Javascript :: google removing javascript from chrome 
Javascript :: delete all properties from an javascript object 
Javascript :: preview.cookie-consent.js 
Javascript :: why browser is not detecting my current position 
Javascript :: Assign keys to an object with the same name 
Javascript :: js create element with attributes 
Javascript :: js return vs break in for loop 
Javascript :: immutable js sort ascending and descending order 
Javascript :: create serverless hello-world 
Javascript :: country name based on browser 
Javascript :: go over each line in text nodejs 
Javascript :: point towards mouse wick editor 
Javascript :: ip address pattern regex javascript 
Javascript :: /serveur.js 
Javascript :: tab in textarea javascript 
Javascript :: react auto import sometime not working 
Javascript :: how to change selected link in jquery 
Javascript :: react passport session 
Javascript :: xpath last node 
Javascript :: remove or add class jquery 
Javascript :: js array find first match 
Javascript :: createelement and set prop attr jquery 
Javascript :: localStorage check 
Javascript :: show hide pseudo element jquery 
Javascript :: mengakses gambar didalam asset angular 
Javascript :: javascript unique id generator 
Javascript :: how to create a snake game in html css js 
ADD CONTENT
Topic
Content
Source link
Name
8+5 =