var var var var sort sort for var console log

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
var n = 3;
var a = [1, 6, 4];
var b = [5, 3, 9];
var s = 0;
a = a.sort();
b = b.sort();
for(var i = 0; i <n; i++){
s+= a[i]*b[i];
}
console.log(s);