Sort an array of objects by a property value

Imagine that we have the next object:

```javascript
const names = [
  { name: 'Sam', lastName: 'Belmor'},
  { name: 'Yasser', lastName: 'Velasco' },
  { name: 'Ayrton', lastName: 'Morales' }
]
```

If we wanna sort those values alpabethically by name we could do this:

> names.sort((a, b) => (a.name > b.name) ? 1 : -1)

We'll have this result:

```javascript
[
  { name: 'Ayrton', lastName: 'Morales' },
  { name: 'Sam', lastName: 'Belmor' },
  { name: 'Yasser', lastName: 'Velasco' }
]
```

If return **_1_**, the function communicates to **_sort()_** that the object **_b_** takes precedence in sorting over the object **_a_**. Returning **_-1_** would do the opposite.

samantha-bello
November 16, 2021
