diff --git a/web-ui/src/main/resources/catalog/components/thesaurus/ThesaurusService.js b/web-ui/src/main/resources/catalog/components/thesaurus/ThesaurusService.js index d444e9a1c3f..686f565960b 100644 --- a/web-ui/src/main/resources/catalog/components/thesaurus/ThesaurusService.js +++ b/web-ui/src/main/resources/catalog/components/thesaurus/ThesaurusService.js @@ -192,7 +192,7 @@ return result; }; - var parseKeywordsResponse = function (data, dataToExclude) { + var parseKeywordsResponse = function (data, dataToExclude, orderById) { var listOfKeywords = []; var uiLangs = getUILangs(); @@ -202,6 +202,19 @@ } }); + listOfKeywords.sort(function(k1,k2) { + var s1; + var s2; + if (orderById == "true") { + s1 = k1.props.uri; + s2 = k2.props.uri; + } else { + s1 = k1.label.toLowerCase(); + s2 = k2.label.toLowerCase(); + } + return s1.localeCompare(s2); + }); + if (dataToExclude && dataToExclude.length > 0) { // Remove from search already selected keywords listOfKeywords = $.grep(listOfKeywords, function (n) { @@ -303,20 +316,7 @@ config.outputLang ), filter: function (data) { - if (config.orderById == "true") { - data.sort(function (a, b) { - var nameA = a.uri.toUpperCase(); - var nameB = b.uri.toUpperCase(); - if (nameA < nameB) { - return -1; - } - if (nameA > nameB) { - return 1; - } - return 0; - }); - } - return parseKeywordsResponse(data, config.dataToExclude); + return parseKeywordsResponse(data, config.dataToExclude, config.orderById); } } });