fixed claim list sorting algo

This commit is contained in:
bill bittner 2017-06-19 16:37:56 -07:00
parent 7eaf82100e
commit 04f1406c73

View file

@ -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;