I am iterating through a JSON object of the following type:
"entries": [{
"first_name": "Brigitte",
"last_name": "Bardot",
"country": "Paris, France",
"profession": "Actress"
},
{
"first_name": "Apollo",
"last_name": "AA",
"country": "Witten, Germany",
"profession": "Writer"
}]
Using v-for and lodash I have an alphabetically ordered list of these entries:
<div v-for="user in orderedUsers" :key='user' class="user">
<p>{{ user.first_name }} {{ user.last_name }} ({{ user.country }}), {{ user.profession }}</p>
</div>
I would like to create a header containing the first letter of the last name, in order to group the entries alphabetically as so:
A
Apollo
B
Bardot
etc..
The function I am using to sort through the entries is the following:
computed: {
orderedUsers: function () {
return orderBy(this.text[0].entries, 'last_name')
}
}
Any ideas on a simple and efficient way to achieve this?