{"size": 793, "ext": "js", "max_stars_repo_path": "frontend/react/utils.js", "max_stars_repo_name": "kamyarg/payments-frontend", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "frontend/react/utils.js", "max_issues_repo_name": "kamyarg/payments-frontend", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "frontend/react/utils.js", "max_forks_repo_name": "kamyarg/payments-frontend", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 29.3703703704, "max_line_length": 59, "alphanum_fraction": 0.5472887768}


// Inspired by http://stackoverflow.com/a/11792417/1329429
export function getMaxNOfArray(arr, N, key){
    if (arr.length < N) {
    	return arr.sort((lhs, rhs) => rhs[key] - lhs[key]);
    }
    var initialObj = {};
    initialObj[key] = Number.NEGATIVE_INFINITY;
    var result = Array(N).fill(initialObj);

    for (var i = 0; i < arr.length; i++){
    	var currentMin = Number.POSITIVE_INFINITY;
    	var currentMinIndex = -1;
        for (var j = 0; j < result.length; j++){
            if (result[j][key] < currentMin){
            	currentMin = result[j][key];
            	currentMinIndex = j;
            }
        }
        if (currentMin < arr[i][key]) {
            result[currentMinIndex] = arr[i];
        }
    }
    return result.sort((lhs, rhs) => rhs[key] - lhs[key]); 
}
