From 36d6bf83a92153ed8ed7659111a280bb7cc2dc94 Mon Sep 17 00:00:00 2001 From: jgould Date: Mon, 1 Aug 2016 15:37:33 -0400 Subject: [PATCH] matches on top sort order --- src/matrix/sort_key.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/matrix/sort_key.js b/src/matrix/sort_key.js index 925115e..300b526 100644 --- a/src/matrix/sort_key.js +++ b/src/matrix/sort_key.js @@ -2,13 +2,19 @@ morpheus.MatchesOnTopSortKey = function (project, modelIndices, name) { var modelHighlight = {}; var p = project; var viewIndices = []; - for (var i = 0, length = modelIndices.length; i < length; i++) { - modelHighlight[modelIndices[i]] = true; + for (var i = 0, j = modelIndices.length, length = modelIndices.length; i < length; i++, j--) { + modelHighlight[modelIndices[i]] = j; viewIndices.push(i); } this.comparator = function (i1, i2) { - var a = modelHighlight[i1] === undefined ? 0 : 1; - var b = modelHighlight[i2] == undefined ? 0 : 1; + var a = modelHighlight[i1]; + if (a === undefined) { + a = 0; + } + var b = modelHighlight[i2]; + if (b === undefined) { + b = 0; + } return (a > b ? -1 : (a === b ? 0 : 1)); }; this.indices = viewIndices; -- GitLab