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:
Vse Mozhe Buty 2020-10-10 21:22:06 +03:00 committed by GitHub
parent edef0b4306
commit 3188466967
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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 };