Vue

by ujjumaki

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-vue/2.21.2/bootstrap-vue.min.js"></script>
<div id="app">
  <table>
    <tr>
      <th><b>First Name  &nbsp;</b></th>
      <th><b> Last Name &nbsp;</b> </th>
      <th><b> ID </b> </th>
    </tr>
    <tr v-for="fetchName in todos.player_name">
      <td>{{fetchName.first_name}}</td>
      <td>{{fetchName.last_name}}</td>
      <td>{{fetchName.id}}</td>
    </tr>
  
  </table>
  <br>
  <button v-on:click=alertName()>Sort by first name</button>
</div>

CSS

body {
  background: #20262E;
  padding: 20px;
  font-family: Helvetica;
}

#app {
  background: #fff;
  border-radius: 4px;
  padding: 20px;
  transition: all 0.2s;
}

li {
  margin: 8px 0;
}

h2 {
  font-weight: bold;
  margin-bottom: 15px;
}

del {
  color: rgba(0, 0, 0, 0.3);
}

Vue

new Vue({
  el: "#app",
  data(){
  return{
    todos: {
    	mission:1,
      player_name:[
      	{	
        	first_name: "Harry", last_name: "Kui" , id:'103',
        },
        {
        	first_name: "Ali", last_name: "Kui", id:'107',
        },
        {
        	first_name: "Bee", last_name: "Hui", id:'99',
        }
      ]
    }
  }
  },
  methods: {
    alertName: function(){
    	this.todos.player_name.sort(); /** sort function is throwing an error here **/
      console.log(this.todos.player_name);
    }
  }
})