You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
openNG/lib/riot/mixins/util/sort-dockables.js

36 lines
636 B
JavaScript

'use strict';
module.exports = function (a, b) {
var aOrder = void 0,
bOrder = void 0;
if (a.order != null) {
aOrder = parseInt(a.order);
}
if (b.order != null) {
bOrder = parseInt(b.order);
}
if (aOrder != null && bOrder == null) {
return -1;
} else if (aOrder == null && bOrder != null) {
return 1;
} else if (aOrder != null && bOrder != null) {
if (aOrder < bOrder) {
return -1;
} else if (aOrder > bOrder) {
return 1;
} else {
return 0;
}
} else {
if (a.stackIndex < b.stackIndex) {
return -1;
} else if (a.stackIndex > b.stackIndex) {
return 1;
} else {
return 0;
}
}
};