Skip to content

Commit 3188466

Browse files
authored
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).
1 parent edef0b4 commit 3188466

File tree

1 file changed

+1
-1
lines changed
  • 1-js/05-data-types/05-array-methods/8-sort-objects

1 file changed

+1
-1
lines changed

1-js/05-data-types/05-array-methods/8-sort-objects/solution.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
```js run no-beautify
22
function sortByAge(arr) {
3-
arr.sort((a, b) => a.age > b.age ? 1 : -1);
3+
arr.sort((a, b) => a.age - b.age);
44
}
55

66
let john = { name: "John", age: 25 };

0 commit comments

Comments
 (0)