Open2

JavaScript自由帳

yukijiyukiji

配列の中のオブジェクトのある値で降順に並べ替え

const languages = [ 'VimL', 'ykj-rails' ];
 mostPopularRepos = fetch(`https://api.github.com/users/${languages[0]}/repos`)
        .then((res) => {
          return res.json();
        })
        .then((repos) => {
          repos.sort((a, b) => {
            return b.stargazers_count - a.stargazers_count
          })
          console.log(repos)
        })