JavaScript A more efficiently/performant way to add elements and sort an array

My function below returns an object containing the sorted playerPoints passed in via the "array of objects" parameter. Without modifying the passed in array, is there a more efficient/performant way to add elements and sort the array in ascending order?

Note: The array of objects could contain one or more objects. In terms of efficiency, I'm referring to completion time (speed). Also the function, ascendingSort is required and can't be replaced.

var data = [{playerPoints: 10}, {playerPoints: 8}, {playerPoints: 2}, {playerPoints: 21},{playerPoints: 30}];

function ascendingSort(players) {
	var points = [];
	for(var i = 0; i < players.length; i++) {
		points.push(players[i].playerPoints);
	}
	points.sort(function(a, b) {return a - b;});
	return {sortedPoints: points};
}

var obj = ascendingSort(data);
console.log(obj);
Answer:1

I tried in my chrome debug console: >function m(){function toString(){return "abc"}} undefined >new m().toString() "[object Object]" I expect it to print "abc". Why?

I tried in my chrome debug console: >function m(){function toString(){return "abc"}} undefined >new m().toString() "[object Object]" I expect it to print "abc". Why?

I'm trying to implement automatic formatting to an web-page. So that when you type 12345678, it is automatically €123.456,78. <div class="form-group"> <input type="text" required class=...

I'm trying to implement automatic formatting to an web-page. So that when you type 12345678, it is automatically €123.456,78. <div class="form-group"> <input type="text" required class=...

How to set AllowColumnResize=true at client side using javascript in master pages using the CSS selector , so that it would apply to all the grid specified with . My effort- function pageLoad() ...

How to set AllowColumnResize=true at client side using javascript in master pages using the CSS selector , so that it would apply to all the grid specified with . My effort- function pageLoad() ...

I know redux is strict with state management, but is adding a value from an array of objects considered a no no in redux? Example: // Consider this array of objects on action action.arr = [ { ...

I know redux is strict with state management, but is adding a value from an array of objects considered a no no in redux? Example: // Consider this array of objects on action action.arr = [ { ...

  1. add value inside array javascript
  2. add value inside array
  3. add value inside javascript
  4. jquery add value inside div