fork(1) download
  1. // your code goes here
  2. var cities = [
  3. {'city' : 'Джакарта', 'country' : 'Индонезия', 'population': 29959},
  4. {'city' : 'Дели', 'country' : 'Индия', 'population': 24134},
  5. {'city' : 'Сеул', 'country' : 'Корея', 'population': 22992},
  6. {'city' : 'Манила', 'country' : 'Филиппины', 'population': 22710},
  7. {'city' : 'Шанхай', 'country' : 'КНР', 'population': 22650},
  8. {'city' : 'Карачи', 'country' : 'Пакистан', 'population': 21585},
  9. {'city' : 'Токие', 'country' : 'Япония', 'population': 37555}
  10. ];
  11.  
  12.  
  13. function get_most(count, cities){
  14. if(count > cities.length){
  15. throw 'Nope';
  16. }
  17. var sort_cities = cities.slice();
  18. sort_cities.sort(function(first_city, last_city){
  19. return last_city.population - first_city.population;
  20. });
  21. return sort_cities.slice(0, count);
  22.  
  23. }
Success #stdin #stdout 0.02s 4980KB
stdin
Standard input is empty
stdout
Standard output is empty