From 956aaa91f3b8aa03148647ee1c389d808af24865 Mon Sep 17 00:00:00 2001 From: Xavier Shay Date: Sun, 30 Jun 2019 00:53:46 +1000 Subject: [PATCH] fix: Deterministic sorting of search results. (#343) * Deterministic sorting of search results. This is important for reliable tests, e.g. if you are snapshotting views and comparing to reference images. * fix prettier --- src/utils/emoji-index/nimble-emoji-index.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/utils/emoji-index/nimble-emoji-index.js b/src/utils/emoji-index/nimble-emoji-index.js index 42f2bfb..7f8a7cd 100644 --- a/src/utils/emoji-index/nimble-emoji-index.js +++ b/src/utils/emoji-index/nimble-emoji-index.js @@ -181,7 +181,11 @@ export default class NimbleEmojiIndex { var aScore = scores[a.id], bScore = scores[b.id] - return aScore - bScore + if (aScore == bScore) { + return a.id.localeCompare(b.id) + } else { + return aScore - bScore + } }) }