Skip to content

Commit

Permalink
Merge pull request #415 from RohitPaul0007/patch-58
Browse files Browse the repository at this point in the history
Update sort.js
  • Loading branch information
rustedgrail authored Sep 11, 2023
2 parents 940299a + a0204ba commit 76ff416
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/order/sort.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
var util = require("../util");
let util = require("../util");

module.exports = sort;

function sort(entries, biasRight) {
var parts = util.partition(entries, entry => {
let parts = util.partition(entries, entry => {
return entry.hasOwnProperty("barycenter");
});
var sortable = parts.lhs,
let sortable = parts.lhs,
unsortable = parts.rhs.sort((a, b) => b.i - a.i),
vs = [],
sum = 0,
Expand All @@ -25,7 +25,7 @@ function sort(entries, biasRight) {
vsIndex = consumeUnsortable(vs, unsortable, vsIndex);
});

var result = { vs: vs.flat(true) };
let result = { vs: vs.flat(true) };
if (weight) {
result.barycenter = sum / weight;
result.weight = weight;
Expand All @@ -34,7 +34,7 @@ function sort(entries, biasRight) {
}

function consumeUnsortable(vs, unsortable, index) {
var last;
let last;
while (unsortable.length && (last = unsortable[unsortable.length - 1]).i <= index) {
unsortable.pop();
vs.push(last.vs);
Expand Down

0 comments on commit 76ff416

Please sign in to comment.