Skip to content

Commit

Permalink
sort packages tab by score
Browse files Browse the repository at this point in the history
  • Loading branch information
jeroen committed Jul 22, 2024
1 parent ce025e4 commit 38ad1f6
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion routes/universe.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ function sort_by_package(x,y){
return x.Package.toLowerCase() < y.Package.toLowerCase() ? -1 : 1
}

function sort_by_score(x,y){
return x._score > y._score ? -1 : 1
}

function format_count(count){
if(count > 1000000) {
return (count/1000000).toFixed(1) + 'M';
Expand Down Expand Up @@ -98,7 +102,7 @@ router.get("/packages", function(req, res, next){
res.render('packages', {
format_count: format_count,
format_time_since: format_time_since,
pkgdata: pkgdata
pkgdata: pkgdata.sort(sort_by_score)
});
}).catch(next);
});
Expand Down

0 comments on commit 38ad1f6

Please sign in to comment.