What function to sort such an array by last name?

var people = [ { "имя": "Иван", "фамилия": "Иванов" }, { "имя": "Петр", "фамилия": "Петров" }, { "имя": "Стас", "фамилия": "Стасов" } ]; 

    1 answer 1

     people.sort(function(a, b){ return a["фамилия"].charCodeAt(0) - b["фамилия"].charCodeAt(0); }); 

    This is a sort by the first letter of the last name. In principle, you can write a cycle to the end.
    http://javascript.ru/Array/sort