Sorted Array in Javascript