From e6c8eb3c61043e708ac48ec4462f4823be63dc1b Mon Sep 17 00:00:00 2001 From: Kyle Shockey Date: Thu, 13 Jul 2017 21:02:37 -0700 Subject: [PATCH] Pass tag names to tagsSorter instead of taggedOperations values --- src/core/plugins/spec/selectors.js | 12 +++++++----- src/core/utils.js | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/core/plugins/spec/selectors.js b/src/core/plugins/spec/selectors.js index c9b31cf1..82056b7e 100644 --- a/src/core/plugins/spec/selectors.js +++ b/src/core/plugins/spec/selectors.js @@ -202,12 +202,14 @@ export const operationsWithTags = createSelector( export const taggedOperations = (state) => ({ getConfigs }) => { let { tagsSorter, operationsSorter } = getConfigs() - return operationsWithTags(state) - .sort((operationA, operationB) => { - let sortFn = (typeof tagsSorter === "function" ? tagsSorter : sorters.tagsSorter[ tagsSorter ]) - return (!sortFn ? null : sortFn(operationA, operationB)) - }) + .sortBy( + (val, key) => key, // get the name of the tag to be passed to the sorter + (tagA, tagB) => { + let sortFn = (typeof tagsSorter === "function" ? tagsSorter : sorters.tagsSorter[ tagsSorter ]) + return (!sortFn ? null : sortFn(tagA, tagB)) + } + ) .map((ops, tag) => { let sortFn = (typeof operationsSorter === "function" ? operationsSorter : sorters.operationsSorter[ operationsSorter ]) let operations = (!sortFn ? ops : ops.sort(sortFn)) diff --git a/src/core/utils.js b/src/core/utils.js index f4b925f6..677b8d90 100644 --- a/src/core/utils.js +++ b/src/core/utils.js @@ -576,7 +576,7 @@ export const sorters = { method: (a, b) => a.get("method").localeCompare(b.get("method")) }, tagsSorter: { - alpha: (a, b) => a.getIn([0, "operation", "tags", 0]).localeCompare(b.getIn([0, "operation", "tags", 0])) + alpha: (a, b) => a.localeCompare(b) } }