Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
sorting by last name
  • Loading branch information
mir12007 committed Apr 17, 2017
1 parent f3ac47c commit 5492385
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion js/main.js
Expand Up @@ -4,10 +4,21 @@ function getStuff () {

ajaxCall.onreadystatechange = function () {

var json = JSON.parse(ajaxCall.responseText);

json.sort(function(a, b){
var nameA=a.lastname.toLowerCase(), nameB=b.lastname.toLowerCase()
if (nameA < nameB)
return -1
if (nameA > nameB)
return 1
return 0
})


if (ajaxCall.readyState == 4 && ajaxCall.status == 200) {

var json = JSON.parse(ajaxCall.responseText);


for (i = 0; i < json.length; i++) {

Expand Down

0 comments on commit 5492385

Please sign in to comment.