Make 'sortWorldInfoEntries' custom sortable

dee4ad8794f3f146eab49d94606d46025ee8989c

Wolfsblvt <wolfsblvt@gmail.com>

1 files changed, +6 -4Ignore whitespace
public/scripts/world-info.js+6 -4
@@ -1642,13 +1642,15 @@ function getWIElement(name) {
1642 * Sorts the given data based on the selected sort option1642 * Sorts the given data based on the selected sort option
1643 *1643 *
1644 * @param {any[]} data WI entries1644 * @param {any[]} data WI entries
1645 * @param {object} [options={}] - Optional arguments
1646 * @param {{sortField?: string, sortOrder?: string, sortRule?: string}} [options.customSort={}] - Custom sort options, instead of the chosen UI sort
1645 * @returns {any[]} Sorted data1647 * @returns {any[]} Sorted data
1646 */1648 */
1647export function sortWorldInfoEntries(data) {1649export function sortWorldInfoEntries(data, { customSort = null } = {}) {
1648 const option = $('#world_info_sort_order').find(':selected');1650 const option = $('#world_info_sort_order').find(':selected');
1649 const sortField = option.data('field');1651 const sortField = customSort.sortField ?? option.data('field');
1650 const sortOrder = option.data('order');1652 const sortOrder = customSort.sortOrder ?? option.data('order');
1651 const sortRule = option.data('rule');1653 const sortRule = customSort.sortRule ?? option.data('rule');
1652 const orderSign = sortOrder === 'asc' ? 1 : -1;1654 const orderSign = sortOrder === 'asc' ? 1 : -1;
16531655
1654 if (!data.length) return data;1656 if (!data.length) return data;