Fix issue with sort functions

This commit is contained in:
Mo Bitar
2018-11-25 19:09:25 -06:00
parent 17cf86a936
commit 79c520e5c8
3 changed files with 15 additions and 4 deletions

View File

@@ -11,7 +11,9 @@ class ActionsMenu {
controller($scope, modelManager, actionsManager) {
'ngInject';
$scope.extensions = actionsManager.extensions.sort((a, b) => {return a.name.toLowerCase() > b.name.toLowerCase()});
$scope.extensions = actionsManager.extensions.sort((a, b) => {
return a.name.toLowerCase() < b.name.toLowerCase() ? -1 : 1;
});
for(let ext of $scope.extensions) {
ext.loading = true;

View File

@@ -15,8 +15,13 @@ class EditorMenu {
$scope.formData = {};
$scope.editors = componentManager.componentsForArea("editor-editor").sort((a, b) => {return a.name.toLowerCase() > b.name.toLowerCase()});
$scope.stack = componentManager.componentsForArea("editor-stack").sort((a, b) => {return a.name.toLowerCase() > b.name.toLowerCase()});
$scope.editors = componentManager.componentsForArea("editor-editor").sort((a, b) => {
return a.name.toLowerCase() < b.name.toLowerCase() ? -1 : 1;
});
$scope.stack = componentManager.componentsForArea("editor-stack").sort((a, b) => {
return a.name.toLowerCase() < b.name.toLowerCase() ? -1 : 1;
});
$scope.isDesktop = isDesktopApplication();

View File

@@ -78,7 +78,11 @@ class SingletonManager {
*/
if(allExtantItemsMatchingPredicate.length >= 2) {
let sorted = allExtantItemsMatchingPredicate.sort((a, b) => {
return a.created_at > b.created_at;
/*
If compareFunction(a, b) is less than 0, sort a to an index lower than b, i.e. a comes first.
If compareFunction(a, b) is greater than 0, sort b to an index lower than a, i.e. b comes first.
*/
return a.created_at < b.created_at ? -1 : 1;
});
// The item that will be chosen to be kept