Skip to content

Instantly share code, notes, and snippets.

@hugofcampos
Last active August 24, 2022 23:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hugofcampos/15c380573867749953d8fed4b0876e14 to your computer and use it in GitHub Desktop.
Save hugofcampos/15c380573867749953d8fed4b0876e14 to your computer and use it in GitHub Desktop.
Passo 3
import ballerina/http;
import ballerina/io;
type GithubAccount record {
int id;
string login;
int public_repos;
};
public function main() returns error? {
string[] usernames = ["defunkt", "zenorocha", "tj"];
GithubAccount[] users = [];
foreach string login in usernames {
http:Client github = check new ("https://api.github.com");
GithubAccount user = check github->get("/users/" + login);
users.push(user);
}
GithubAccount[] sorted = from GithubAccount u in users
order by u.public_repos descending
select u;
io:println(sorted[0].login);
return;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment