Skip to content

Instantly share code, notes, and snippets.

@dfabulich
dfabulich / starsort.js
Last active September 25, 2023 02:45
Evan Miller Ranking Items with Star Ratings, in JavaScript
"use strict";
// based on unutbu's stackoverflow answer
// https://stackoverflow.com/a/40958702/54829
// which is based on Evan Miller's blog post
// http://www.evanmiller.org/ranking-items-with-star-ratings.html
function starsort(ratings) {
function sum(array) { return array.reduce((x, y) => x + y, 0) };