Java Array Sorting Algorithm In Javascript Object