Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

array sort using for loop in javascript

var Arr = [1, 7, 2, 8, 3, 4, 5, 0, 9];

for (var i = 1; i < Arr.length; i++)
    for (var j = 0; j < i; j++)
        if (Arr[i] < Arr[j]) {
          var x = Arr[i];
          Arr[i] = Arr[j];
          Arr[j] = x;
        }

console.log(Arr);
 Run code snippetHide results
Comment

PREVIOUS NEXT
Code Example
Javascript :: reload page jquery timer 
Javascript :: js 1 second delay 
Javascript :: js wait 1 second 
Javascript :: javascript capitalize string 
Javascript :: javascript difference between two dates 
Javascript :: chartjs bar chart hover color 
Javascript :: fetch post json 
Javascript :: is string javascript 
Javascript :: counter cdn 
Javascript :: js wait for seconds 
Javascript :: float right react native 
Javascript :: replacing each space in a string javascript 
Javascript :: local storage check if key exists 
Javascript :: disable right click jquery 
Javascript :: update create react app 
Javascript :: joi phone number validation 
Javascript :: on resize jquery 
Javascript :: javascript prevent context menu 
Javascript :: access-control-allow-origin nodejs express 
Javascript :: js fileinput get content 
Javascript :: javascript get table row count 
Javascript :: get the first day and last day of current mongth javascript 
Javascript :: how to get value of button that click on it jquery 
Javascript :: javascript get random number in range 
Javascript :: javascript check if blank space 
Javascript :: how to sort string aray in ts 
Javascript :: javascript code for year in html 
Javascript :: jquery open a new tab 
Javascript :: delete dir nodejs 
Javascript :: console.log ejs 
ADD CONTENT
Topic
Content
Source link
Name
1+9 =