Created
June 24, 2017 12:20
-
-
Save amirkheirabadi73/9ab412c0a27c8fcfe26a84344a109302 to your computer and use it in GitHub Desktop.
Sort Array Object
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
jack: 20, | |
amir: 22, | |
ali: 15, | |
}; | |
sortObject((persons) => { | |
var sortable = []; | |
for (var person in persons) { | |
sortable.push([person, persons[person]]); | |
} | |
sortable.sort(function(a, b) { | |
return a[1] - b[1]; | |
}); | |
return sortable; | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment