Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

sort array with negative numbers

var arr = [10, 5, 40, 25, -3412, 4212, -107.578, 97.453];

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

return arr.sort(sortNumber);
Comment

PREVIOUS NEXT
Code Example
Javascript :: callbacks in jquery 
Javascript :: javascript get last element in array 
Javascript :: mongoose match aggregate 
Javascript :: how do you calculate what percentage a number is of another number 
Javascript :: flatmap js 
Javascript :: eliminar duplicados javascript 
Javascript :: row append and calculation in jquery datatable 
Javascript :: react code input 
Javascript :: javascript random item of array 
Javascript :: math question 
Javascript :: how to create my own filter in js 
Javascript :: Detect Mobile / Computer by Javascript 
Javascript :: set route on button in angular 
Javascript :: javascript detect time on page 
Javascript :: js Changing selected option by option text 
Javascript :: uploading json data to s3 bucket in node js 
Javascript :: js how to fix 0.1 + 0.2 
Javascript :: display form input on console jquery 
Javascript :: jquery-3.5.1.min.js download 
Python :: python generate folder if it not exist 
Python :: opencv show image jupyter 
Python :: pandas see all columns 
Python :: is pythin a real coding language 
Python :: string to datetime convert 
Python :: upgrade python version mc 
Python :: pygame play sound 
Python :: pandas get rows string in column 
Python :: sns set figure size 
Python :: split data validation 
Python :: find common elements in two lists python 
ADD CONTENT
Topic
Content
Source link
Name
4+8 =