Make 'sortWorldInfoEntries' custom sortable

dee4ad8794f3f146eab49d94606d46025ee8989c

Wolfsblvt <wolfsblvt@gmail.com>

1 files changed, +6 -4Showing whitespace changes
public/scripts/world-info.js+6 -4
@@ -1642,13 +1642,15 @@ function getWIElement(name) {
16421642 * Sorts the given data based on the selected sort option
16431643 *
16441644 * @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
16451647 * @returns {any[]} Sorted data
16461648 */
16471649export function sortWorldInfoEntries(data, { customSort = null } = {}) {
16481650 const option = $('#world_info_sort_order').find(':selected');
16491651 const sortField = customSort.sortField ?? option.data('field');
16501652 const sortOrder = customSort.sortOrder ?? option.data('order');
16511653 const sortRule = customSort.sortRule ?? option.data('rule');
16521654 const orderSign = sortOrder === 'asc' ? 1 : -1;
16531655
16541656 if (!data.length) return data;