For ascending
var nlist = [1, 6, 8, 2, 16, 0]
nlist.sort((a, b) => a.compareTo(b));
For descending
var nlist = [1, 6, 8, 2, 16, 0]
nlist.sort((b, a) => a.compareTo(b));
var nlist = [1, 6, 8, 2, 16, 0]
nlist.sort((a, b) => a.compareTo(b));
var nlist = [1, 6, 8, 2, 16, 0]
nlist.sort((b, a) => a.compareTo(b));