Level
프로그래머스 Lv1
Recruitment
// O(n^2 * logn)
function solution5(d, budget) {
  let answer = 0; // 더해진 항목의 개수를 저장
  let total = 0;
  for (let b of d.sort((a, b) => a - b)) {
    total += b;

    if (total > budget) {
      return answer;
    }

    answer++;
  }
  return answer;
}