diff --git a/lib/zin/wg/docapp/js/v1.js b/lib/zin/wg/docapp/js/v1.js index d881a72ce0..0e9e4da5d2 100644 --- a/lib/zin/wg/docapp/js/v1.js +++ b/lib/zin/wg/docapp/js/v1.js @@ -2007,7 +2007,7 @@ function isMatchFilter(type, filterType, item) */ function formatOrders(orders, useIndex) { - const orderedKeys = useIndex ? [] : Array.from(orders).sort(); + const orderedKeys = useIndex ? [] : Array.from(orders).sort((a, b) => a - b); return orders.reduce((map, key, index) => { map[key] = useIndex ? index : orderedKeys[index]; @@ -2078,6 +2078,13 @@ function getSortableOptions(type) if(fromType !== 'doc') key = key.substring(1); orderedList.push(+key); }); + if(fromType === 'doc') + { + const docApp = getDocApp(); + const doc = docApp.getDoc(orderedList[0]); + const lib = doc ? docApp.getLib(doc.lib) : null; + if(lib && typeof lib.data.orderBy === 'string' && lib.data.orderBy.endsWith('desc')) orderedList.reverse(); + } sortItems(fromType, orderedList); } }