Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 141891

Can't sort array containing int

$
0
0

I'm unable to sort an array containing int. Here's my code for the sort :

var asr = [];

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

The function sort doesn't do anything, here is a sample of my array when I made a console.log(asr) on chrome :

by: 3
de: 2
ds: 14
sr: 2
vi: 1

proto: Array(0)


Viewing all articles
Browse latest Browse all 141891

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>