Created
September 26, 2017 02:10
-
-
Save evaporei/a552701da6d7793a5e26eb928a2a49fd to your computer and use it in GitHub Desktop.
Ramda functional exercise 1 - Order users by id
This file contains hidden or 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
const R = require('ramda') | |
const json = { | |
users: [ | |
{id: 3, name: "Thad", age: 36}, | |
{id: 5, name: "Lucian", age: 23}, | |
{id: 2, name: "Justine", age: 29}, | |
{id: 4, name: "Katie", age: 26}, | |
{id: 0, name: "Jerold", age: 52}, | |
{id: 1, name: "Nona", age: 33} | |
] | |
} | |
// exercise 1: order users by id | |
const orderListById = R.sortBy(R.prop('id')) | |
const usersOrderedById = orderListById(json.users) | |
console.log(usersOrderedById) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment