<commit_before>sort-github-user-repos
======================

Sort GitHub repositories by stars for user.<commit_msg>added readme content<commit_after>sort-github-user-repos
======================

Sort GitHub repositories by stars for user.

## Live demo
http://jsfiddle.net/UFYW4/

## Code

### HTML

```html
<!-- https://github.com/IonicaBizau/sort-github-user-repos -->

<div class="repo template">
    <span class="stars">
        <span class="count"></span> ★
    </span>
    <a target="blank" class="name"></a>
</div>
```

### JavaScript (requires jQuery)

```js
function getAllRepos (user, callback, page, repos) {
    page = page || 1;
    repos = repos || [];
    $.getJSON("https://api.github.com/users/" + user + "/repos?per_page=100&page=" + page, function (newRepos) {
        if (newRepos.length) {
            repos = repos.concat(newRepos);
            return getAllRepos (user, callback, ++page, repos);
        }
        callback (null, repos);
    });
}

var $repoTempl = $(".repo.template").clone().removeClass("template");
$(".repo.template").remove();

getAllRepos ("IonicaBizau", function (err, repos) {
    console.log(repos);
    
    repos.sort (function (a, b) {
        return (a.stargazers_count < b.stargazers_count) ? 1 : -1;
    });
    
    for (var i = 0; i < repos.length; ++i) {
        var cRepo = repos[i]
          , $newRepo = $repoTempl.clone()
          ;
        
        $newRepo.find(".stars .count").text(cRepo.stargazers_count);
        $newRepo.find(".name").text(cRepo.name);
        $newRepo.find(".name").attr({
            href: cRepo.html_url
        });
        $("body").append($newRepo);
    }
});
```
{'fraction_non_alphanumeric': 0.20627261761158022, 'fraction_numerical': 0.0048250904704463205, 'mean_word_length': 2.7704545454545455, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 12, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '846867', 'n_tokens_mistral': 581, 'n_tokens_neox': 548, 'n_words': 109}