Make a solution of 1.5.5 task more correct
Proposed solution is in sync with some previous sort function examples. It also makes sorting stable (does not skip `0` result).
This commit is contained in:
parent
edef0b4306
commit
3188466967
1 changed files with 1 additions and 1 deletions
|
@ -1,6 +1,6 @@
|
|||
```js run no-beautify
|
||||
function sortByAge(arr) {
|
||||
arr.sort((a, b) => a.age > b.age ? 1 : -1);
|
||||
arr.sort((a, b) => a.age - b.age);
|
||||
}
|
||||
|
||||
let john = { name: "John", age: 25 };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue