Created
March 26, 2017 15:01
-
-
Save tomatau/236d3068a9c35847837fa2ab9f8f56f9 to your computer and use it in GitHub Desktop.
Sort Arrays
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import assert from 'assert' | |
const sortByAge = (source) => source.sort((itemA, itemB) => itemA.age - itemB.age) | |
const ob = (age) => ({ name: ''+age, age }) | |
assert.deepEqual( | |
sortByAge([ ob(1), ob(6), ob(2), ob(5), ob(3), ob(4) ]), | |
[ ob(1), ob(2), ob(3), ob(4), ob(5), ob(6) ] | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment