From 04f1406c732f6c0004e9e9167fd86f6fac12cccb Mon Sep 17 00:00:00 2001 From: bill bittner Date: Mon, 19 Jun 2017 16:37:56 -0700 Subject: [PATCH] fixed claim list sorting algo --- helpers/functions/getAllFreePublicClaims.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/helpers/functions/getAllFreePublicClaims.js b/helpers/functions/getAllFreePublicClaims.js index 17e8721f..721ecbf4 100644 --- a/helpers/functions/getAllFreePublicClaims.js +++ b/helpers/functions/getAllFreePublicClaims.js @@ -1,8 +1,8 @@ const isFreePublicClaim = require('./isFreePublicClaim.js'); const lbryApi = require('../libraries/lbryApi.js'); +const logger = require('winston'); function filterForFreePublicClaims (claimsListArray) { - // console.log("claims list:", claimsListArray) if (!claimsListArray) { return null; } @@ -16,12 +16,12 @@ function filterForFreePublicClaims (claimsListArray) { } function orderTopClaims (claimsListArray) { - console.log('>> orderTopClaims'); - claimsListArray.sort(({ amountA, heightA }, { amountB, heightB }) => { - if (amountA === amountB) { - return heightA > heightB; + logger.silly('ordering the top claims'); + claimsListArray.sort((a, b) => { + if (a.amount === b.amount) { + return a.height < b.height; } else { - return amountA < amountB; + return a.amount < b.amount; } }); return claimsListArray;