I have many structures like:
student :
 name: SomeName
 city : someSity   
 school : someschool
 date : somedate
What I want is to sort them in a way like (with test data):
Sorted_map:
    city : NY
       school: School1
             name:Name1
             name: Name2
             name: Name4
       shool: School2
             name:Name11
             name: Name21
             name: Name41
    city: WDC  
        school: School3
           name: Name22  
           name: Name29 
What I did is sorting by city :
function groupBy( array , f ) {
    var groups = {};
    array.forEach( function( o )
    {
        var group = JSON.stringify( f(o) );
        groups[group] = groups[group] || [];
        groups[group].push( o );
    });
     return groups;    
}
var result = groupBy(sudentsItems, function(item)
    {
        return unifyCity(item.city);
    }
so now it is sorted only by the "city" key. How do I sort data inside city?
I guess I need something like Map < city_key, Map < school_key, name > >;
Data sample :
[{
    "name":   "John Some",
    "city":   "NY",
    "school": "NY Central",
    "date":   1460986261733
}, {
    "name":   "Sarah Mil",
    "city":   "Moscow",
    "school": "Moscow Central",
    "date":   1460986201733
}, {
    "name":   "John Again",
    "city":   "NY",
    "school": "NY Central",
    "date":   1460986261733
}, {
    "name":   "Kit Parcer",
    "city":   "NY",
    "school": "NY Central",
    "date":   1460086261733
},  {
    "name":   "Anna Love",
    "city":   "SPB",
    "school": "SPB Central",
    "date":   1460983261733
}]
 
     
    