optimal-select icon indicating copy to clipboard operation
optimal-select copied to clipboard

Priority order is not being honored

Open mwhebert opened this issue 7 years ago • 0 comments

Looks like the findAttributesPattern function is not properly sorting the attributes by the priority array properly. Looks like the sort comparison check is not correct. changing the sort code to this below seemed to resolve the issue

var outsidePriority = priority.length + 1; // greater than any priority position var sortedKeys = Object.keys(attributes).sort(function (curr, next) { var currPos = priority.indexOf(attributes[curr].name); var nextPos = priority.indexOf(attributes[next].name);

if (nextPos == -1) nextPos = outsidePriority;
if (currPos == -1) currPos = outsidePriority;

if (nextPos > currPos) { return -1;}
if (nextPos < currPos) { return 1;}
return 0;

/* old code if (nextPos === -1) { if (currPos === -1) { return 0; } return -1; } return currPos - nextPos; */ });

mwhebert avatar Sep 20 '17 13:09 mwhebert