Published on January 26, 2024By DeveloperBreeze

// Array of numbers
const numbers = [4, 2, 8, 1, 6];

// Sorting the array in ascending order
const sortedNumbers = numbers.sort((a, b) => a - b);

// Logging the sorted array
console.log('Sorted Array:', sortedNumbers);

Comments

Please log in to leave a comment.

Continue Reading:

Reversing a String in JavaScript: A Simple Guide

Published on January 26, 2024

javascriptpython

Sort a List

Published on January 26, 2024

python

Sorting a Dictionary by Values

Published on January 26, 2024

python

Sort List of Objects by Attribute in Python

Published on January 26, 2024

python

JavaScript Display To-Do List

Published on January 26, 2024

javascript

JavaScript Check if Array Contains Element

Published on January 26, 2024

javascript

JavaScript Remove Duplicates from an Array

Published on January 26, 2024

javascript

JavaScript Sum of Array Elements

Published on January 26, 2024

javascript

Image Slider

Published on January 26, 2024

javascript

Sorting an Array in JavaScript

Published on January 26, 2024

javascript