I am trying to read data from a JSON file and display it alphabetically. I am getting results but not alphabetically? I am not sure what has gone wrong here.
$.getJSON("data.json", function(data) {
  var user_Data = "";
  var sorted = data.sort(function(a, b) {
    if (name.a > name.b) {
      return 1;
    }
    if (name.a < name.b) {
      return -1;
    }
    return 0;
  });
  $.each(sorted, function(key, value) {
    user_Data += '<p class="user col-md-6">' + value.name + '</p>';
  });
  $("#usernames").append("(" + data.length + ")"); //returns the total amount of contacts
  $("#usernames").append(user_Data);
});
 
     
    